-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmpvyt
More file actions
executable file
·42 lines (34 loc) · 824 Bytes
/
mpvyt
File metadata and controls
executable file
·42 lines (34 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh -e
help() {
cat - >&2 <<EOF
mpvyt - search for youtube videos and play them with mpv
mpvyt [-n num] query...
Only plays 10 videos by default, which can be increased to any number
with the -n option (-n 0 will play an indefinite amount of videos)
Beware that adding videos to the playlist takes time, so a high (or
0) -n value might cause the first video to take quite a while to load.
EOF
}
unset -v n a
while getopts 'han:' o; do
case "$o" in
n)
if [ "$OPTARG" = 0 ]; then
n='all'
else
n="$OPTARG"
fi
;;
a) a=1 ;;
h) help; exit 0 ;;
*) help; exit 1 ;;
esac
done
shift $((OPTIND-1))
if [ ! "$*" ]; then
echo "Can't search for nothing" >&2
exit 1
fi
mpv --force-window=immediate --no-resume-playback \
${a:+--video=no --force-window=no } \
ytdl://ytsearch"${n:-10}":"$*"