diff options
| author | Fuwn <[email protected]> | 2023-09-19 16:52:06 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-09-19 16:52:06 -0700 |
| commit | 8093e287d159413d1b78a01b7d11d934174f7866 (patch) | |
| tree | b7f17a7fb9da0ce23280a0fd0f5bc33bd7a5f0bf /src | |
| parent | feat(readme): update (diff) | |
| download | kaguya-8093e287d159413d1b78a01b7d11d934174f7866.tar.xz kaguya-8093e287d159413d1b78a01b7d11d934174f7866.zip | |
feat(stream): implement url streamer
Diffstat (limited to 'src')
| -rw-r--r-- | src/bashly.yml | 34 | ||||
| -rw-r--r-- | src/stream_command.sh | 73 |
2 files changed, 87 insertions, 20 deletions
diff --git a/src/bashly.yml b/src/bashly.yml index 5615da6..5d06221 100644 --- a/src/bashly.yml +++ b/src/bashly.yml @@ -1,92 +1,86 @@ name: kaguya help: Fuwn's Anime & Manga Utility version: 0.1.0 - commands: - name: anichart alias: ac dependencies: [xdg-open] - - name: myanimelist alias: mal dependencies: [xdg-open] args: - name: profile - - name: anilist alias: al default: force dependencies: [xdg-open] args: - name: profile - - name: crunchyroll alias: cr dependencies: [xdg-open] args: - name: search repeatable: true - - name: hidive alias: hd dependencies: [xdg-open] args: - name: search repeatable: true - - name: watch alias: w dependencies: [ani-cli] args: - name: search repeatable: true - flags: - long: --dub short: -d - - name: character alias: c dependencies: [xdg-open, curl, echo, jq] - args: - name: name required: true repeatable: true - + - name: stream + dependencies: [date, yt-dlp, sed, mplayer, rm] + args: + - name: uri + required: true + flags: + - long: --fix + - long: --download + - long: --username + short: -u + arg: username + - long: --password + short: -p + arg: password - name: x dependencies: [xdg-open, curl, echo, tr, jq] - args: - name: title required: true repeatable: true - flags: - long: --tv conflicts: [--manga --novel] - - long: --manga conflicts: [--tv --novel] - - long: --novel conflicts: [--tv --manga] - - long: --any-tv conflicts: [--tv --manga --novel --any-manga] - - long: --any-manga conflicts: [--tv --manga --novel --any-tv] - - long: --al conflicts: [--mal] - - long: --mal conflicts: [--al] - - long: --both short: -b conflicts: [--al --mal] - - long: --social short: -s diff --git a/src/stream_command.sh b/src/stream_command.sh new file mode 100644 index 0000000..9ae913c --- /dev/null +++ b/src/stream_command.sh @@ -0,0 +1,73 @@ +user_agent="Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0" + +if [[ -n "${args['--download']}" ]]; then + START=$(date +%s) + + yt-dlp \ + --all-subs \ + --cookies-from-browser firefox \ + --embed-subs \ + --external-downloader=aria2c \ + --external-downloader-args \ + '--min-split-size=1M --max-connection-per-server=16 --max-concurrent-downloads=16 --split=16' \ + -f 'best[height=1080]' \ + --remux mkv \ + --merge mkv \ + --verbose \ + --user-agent "${user_agent}" \ + "${args[uri]}" + + printf "\ntook %s seconds\n" $(($(date +%s || true) - START)) + + return +fi + +# mpv "$(yt-dlp \ +# --cookies-from-browser firefox \ +# --extractor-args crunchyrollbeta:hardsub=en-US \ +# -f 'best[height=1080]' \ +# -g \ +# --verbose \ +# "${1}")" + +subtitles_command=( + 'yt-dlp' + '--cookies-from-browser' 'firefox' + '--no-download' + '-o' '/tmp/skyla_subtitles' + '--sub-lang' 'en-US' + '--write-subs' + '--user-agent' "${user_agent}" + "${args[uri]}" +) + +if [ -n "${args['--username']}" ]; then + subtitles_command+=(-u "${args['--username']}") + subtitles_command+=(-p "${args['--password']}") +fi + +"${subtitles_command[@]}" + +if [[ -n "${args['--fix']}" ]]; then + sed -i 's/{an\d*}//g' /tmp/skyla_subtitles.*.ass +fi + +media_command=( + 'yt-dlp' + '--cookies-from-browser' 'firefox' + '-f' 'best[height=1080]' + '-g' + '--user-agent' "${user_agent}" + "${args[uri]}" +) + +if [ -n "${args['--username']}" ]; then + media_command+=(-u "${args['--username']}") + media_command+=(-p "${args['--password']}") +fi + +mplayer \ + -sub /tmp/skyla_subtitles.*.ass \ + "$("${media_command[@]}")" + +rm /tmp/skyla_subtitles.*.ass |