diff options
| author | xyz <gky44px1999@gmail.com> | 2021-09-20 15:50:40 -0700 | 
|---|---|---|
| committer | xyz <gky44px1999@gmail.com> | 2021-09-20 15:50:40 -0700 | 
| commit | d495b210bec31268c6680258200193077bbfe4b5 (patch) | |
| tree | 7c4b4adbdbb04f8164dc05bac146c00fd76712fe | |
| parent | c3c0fbf5dc191688b2bbdf85408c6d6b58376ad4 (diff) | |
mpvy, no tsp for -a
| -rwxr-xr-x | .local/bin/mpvy | 26 | 
1 files changed, 10 insertions, 16 deletions
| diff --git a/.local/bin/mpvy b/.local/bin/mpvy index 31433522..01f40ffa 100755 --- a/.local/bin/mpvy +++ b/.local/bin/mpvy @@ -3,19 +3,18 @@  # https://www.rockyourcode.com/til-how-to-watch-youtube-videos-with-mpv-and-keyboard-shortcuts/  # https://github.com/mpv-player/mpv/issues/7792 -notify () -{ -	notify-send "mpvsel failed" -} -  fps=30  height=$SCRHEIGHT  url="$(xsel -ob)"  flag=s -# can improve to make s and d mutually exclusive, see curlncm, maybe not, not necessary +notify () +{ +	notify-send 'mpvsel failed' +} + +# 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? -# how to simplify notify-send  while getopts Aad:f:h:su: opt; do  	case $opt in  		# s: streaming, a: aria2c then mpv, A: aria2c @@ -27,20 +26,15 @@ while getopts Aad:f:h:su: opt; do  		\?) exit 1;;  	esac  done -case $flag in -	A) [ -z "$download_dir" ] && download_dir="$XDG_DOWNLOAD_DIR/mpvsel/";; -	a) [ -z "$download_dir" ] && download_dir="/tmp/mpvsel/";; -esac -mkdir -p "$download_dir"  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" +# 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 -	A) yt-dlp -f "$format" --embed-subs -P "$download_dir" --sponsorblock-remove all "$url" || notify;; -	a) yt-dlp -f "$format" --embed-subs -P "$download_dir" --sponsorblock-remove all "$url" --exec "mpv --fs --speed=2" || notify;; +	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;;  esac | 
