+ rudimentary youtube support
commit
4df1fe12f7
|
@ -0,0 +1,15 @@
|
|||
# play.sh
|
||||
|
||||
Searches for a song and launches a player (mpv) so you can enjoy the music ASAP. Currently only works with yt-dlp.
|
||||
|
||||
```
|
||||
paula@ryuko:~/play$ ./play.sh "mixed nuts official"
|
||||
Found search in query cache. Wanna skip querying? [Yn]y
|
||||
(+) Audio --aid=1 --alang=eng (*) (opus 2ch 48000Hz)
|
||||
Subs --sid=1 --slang=en 'vtt' (webvtt) (external)
|
||||
Subs --sid=2 --slang=ja 'vtt' (webvtt) (external)
|
||||
AO: [alsa] 48000Hz stereo 2ch float
|
||||
|
||||
A: 00:00:11 / 00:04:02 (5%) Cache: 230s/9MB
|
||||
|
||||
```
|
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
player="mpv"
|
||||
cachedir=~/.cache/play
|
||||
mkdir -p "$cachedir"
|
||||
touch "$cachedir/query"
|
||||
cache="$(grep -F "$1" "$cachedir/query")"
|
||||
IFS=$'\1'
|
||||
|
||||
function yt_search() {
|
||||
res=($(yt-dlp ytsearch10:"$1" --flat-playlist -J | jq -r '.entries[] | "\(.title)'$'\01''\(.url)'$'\01''"' | tr -d '\n'))
|
||||
|
||||
for (( i=0; i<${#res[@]}; i=i+2 )); do
|
||||
echo "$(((i+2)/2)). ${res[$i]} ${res[$((num+1))]}"
|
||||
done
|
||||
|
||||
read -p "Meow? " num
|
||||
meow="${res[$((num*2+1))]}"
|
||||
echo "$meow"'$'\01''"$1" > "$cachedir/query"
|
||||
}
|
||||
|
||||
if [[ "$cache" != '' ]]; then
|
||||
read -p "Found search in query cache. Wanna skip querying? [Yn]" yn
|
||||
if [[ $yn == "n" ]]; then
|
||||
yt_search "$1"
|
||||
else
|
||||
meow="${cache//$'\01'*}"
|
||||
fi
|
||||
else
|
||||
yt_search "$1"
|
||||
fi
|
||||
|
||||
mpv --ytdl-format="251/250/140" "$meow"
|
Loading…
Reference in New Issue