diff options
author | xyz <gky44px1999@gmail.com> | 2021-09-20 21:49:27 -0700 |
---|---|---|
committer | xyz <gky44px1999@gmail.com> | 2021-09-20 21:49:27 -0700 |
commit | 21b247f1d0a6381a66c3123a43f2e6ba74e22d53 (patch) | |
tree | 6120989b8f1c674c0cbdda824896ebcfcbdc3eee | |
parent | e0d28d66c41773b7310da0c76cefa55264be0a3a (diff) |
refactor
-rwxr-xr-x | .local/bin/mpvy | 17 | ||||
-rwxr-xr-x | .local/bin/upd | 6 |
2 files changed, 13 insertions, 10 deletions
diff --git a/.local/bin/mpvy b/.local/bin/mpvy index 01f40ffa..26fc1fb5 100755 --- a/.local/bin/mpvy +++ b/.local/bin/mpvy @@ -15,10 +15,11 @@ notify () # can improve to make s, a, A mutually exclusive, see curlncm, maybe not, not necessary # option f and h may do nothing if redownload? since same filename exist, haven't tested. yt-dlp won't download same file even without --auto-file-renameing=false. how improve? -while getopts Aad:f:h:su: opt; do +while getopts Aabd:f:h:su: opt; do case $opt in # s: streaming, a: aria2c then mpv, A: aria2c A|a|s) flag=$opt;; + b) format='bestvideo+bestaudio/best';; d) download_dir="$OPTARG";; f) fps="$OPTARG";; h) height="$OPTARG";; @@ -26,14 +27,16 @@ while getopts Aad:f:h:su: opt; do \?) exit 1;; esac done -vformat="[height<=?$height][fps<=?$fps][vcodec!^=?vp9][vcodec!^=?av01]" -# usually with my vformat, video is .mp4, bestaudio is .webm, seems not a good idea to combine those, create problems when use yt-dlp to merge them, not sure about streaming -#format="bestvideo$vformat+bestaudio/best$vformat" -format="best$vformat" +if [ -z "$format" ]; then + vformat="[height<=?$height][fps<=?$fps][vcodec!^=?vp9][vcodec!^=?av01]" + # usually get .mp4 video + .webm audio on youtube, yt-dlp needs to merge them to .mkv + # it used to cause problem, but I forget + format="bestvideo$vformat+bestaudio/best$vformat" +fi -# here if use --write-sub, mpv doesn't recognize subtitles? -# --embed-subs is a little bit better case $flag in + # here if use --write-sub, mpv doesn't recognize subtitles? + # --embed-subs is a little bit better, but still worse then direct streaming A) tsp yt-dlp -f "$format" --embed-subs -P "${download_dir:-"$XDG_DOWNLOAD_DIR/mpvy/"}" --sponsorblock-remove all "$url";; a) yt-dlp -f "$format" --embed-subs -P "${download_dir:-/tmp/mpvy/}" --sponsorblock-remove all "$url" --exec 'mpv --fs --speed=2' || notify ;; s) mpv --ytdl-format="$format" --ytdl-raw-options='write-sub=' --fs --speed=2 "$url" || notify;; diff --git a/.local/bin/upd b/.local/bin/upd index 6ef166ac..06e527a1 100755 --- a/.local/bin/upd +++ b/.local/bin/upd @@ -45,10 +45,10 @@ ncm () pac () { - yes | sudo pacman -Syu - yes | paru -Syu + sudo pacman --noconfirm -Syu + paru --noconfirm -Syu # not fully understand - rm ~/.cache/paru/clone/neovim-nightly-bin/ -rf && paru --rebuild --redownload neovim-nightly-bin + #rm ~/.cache/paru/clone/neovim-nightly-bin/ -rf && yes 1 | paru --rebuild --redownload neovim-nightly-bin sudo pacman -Fy } |