summaryrefslogtreecommitdiff
path: root/home/xyz/.local/bin/mpva
blob: 7224cf46b870b3cfbf250244c6ff2b5e0e0093eb (plain)
1
2
3
4
5
6
7
8
9
10
11
#!/bin/sh

if [ $# -eq 0 ]; then
	# fzf has --read0, maybe useful
	find "$XDG_MUSIC_DIR" | fzf -m --print0 | xargs -0 mpv --af= --shuffle --loop-playlist=inf --video=no
elif [ $# -eq 1 ]; then
	# use --loop-file for single file, better performance maybe
	mpv --af= --loop-file=inf --video=no "$1"
else
	mpv --af= --shuffle --loop-playlist=inf --video=no "$@"
fi
an>a|s) flag=$opt;; b) format='bestvideo+bestaudio/best';; d) download_dir="$OPTARG";; f) fps="$OPTARG";; h) height="$OPTARG";; u) url="$OPTARG";; \?) exit 1;; esac done 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 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) 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';; s) mpv --ytdl-format="$format" --ytdl-raw-options='write-sub=' --fs --speed=2 "$url";; esac # not sure if this is the best practice, but it seems working ;) status=$? [ $status -ne 0 ] && notify-send 'mpvsel failed' exit $status