startmpv uses curl and jq instead of external software now
This commit is contained in:
parent
c784764e31
commit
1b13b44699
@ -5,10 +5,14 @@ if echo "$1" | grep -qE 'youtube.*list'; then
|
|||||||
js_playlist_index_loc="$HOME/src/youtube-playlist-video-ids"
|
js_playlist_index_loc="$HOME/src/youtube-playlist-video-ids"
|
||||||
# The above mentioned script needs Youtube API access, (see the repo for more info on that)
|
# The above mentioned script needs Youtube API access, (see the repo for more info on that)
|
||||||
# I've saved my API key in my password manager, I reccomend you to do something similar.
|
# I've saved my API key in my password manager, I reccomend you to do something similar.
|
||||||
API_key="$(pass show 'Misc/Youtube Data API v3')"
|
API_key="$(pass show 'Misc/Youtube Data API v3' | head -n1 )"
|
||||||
playlist_id="$( echo "$1" | perl -pe "s|^.*?(\?\|&)list=(.*?)|\2|; s|&index=[0-9]+||" )"
|
playlist_id="$( echo "$1" | perl -pe "s|^.*?(\?\|&)list=(.*?)|\2|; s|&index=[0-9]+||" )"
|
||||||
notify-send "startmpv" "Searching for all videos in playlist..."
|
notify-send "startmpv" "Searching for all videos in playlist..."
|
||||||
npm start --prefix "$js_playlist_index_loc" -- --api-key "$API_key" --playlist-id $playlist_id | sed 's/^/https:\/\/www.youtube.com\/watch?v=/' | xargs mpv || notify-send "startmpv" "An error has occured with playlist $playlist_id"
|
curl "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=500&playlistId=$playlist_id&key=$API_key" |
|
||||||
|
jq '."items"[]."snippet"."resourceId"."videoId"' |
|
||||||
|
sed 's/^/https:\/\/www.youtube.com\/watch?v=/' |
|
||||||
|
xargs mpv --ytdl-format='bestvideo[ext=mp4][width<=1920][height<=1080]+bestaudio[ext=m4a]/best[ext=mp4]/best' ||
|
||||||
|
notify-send "startmpv" "An error has occured with playlist $playlist_id"
|
||||||
else
|
else
|
||||||
mpv "$1"
|
mpv --ytdl-format='bestvideo[ext=mp4][width<=1920][height<=1080]+bestaudio[ext=m4a]/best[ext=mp4]/best' "$1"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user