From 90990f5928b3afe4e1870104d4e497a2efcb936d Mon Sep 17 00:00:00 2001 From: Dominika Date: Sun, 9 Aug 2020 03:00:18 +0200 Subject: [PATCH] autoplay on videos (playlist only, will make it nicer later), playlist videos now automatically forward to the next one --- webroot/yt/playlist.shs | 2 +- webroot/yt/watch.shs | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/webroot/yt/playlist.shs b/webroot/yt/playlist.shs index 118cc7c..5dd353a 100644 --- a/webroot/yt/playlist.shs +++ b/webroot/yt/playlist.shs @@ -15,5 +15,5 @@ video_title=($(jq -r '.title' <<< $data)) video_id=($(jq -r '.id' <<< $data)) for (( i=0; i<${#video_id[@]}; i++ )); do - echo "
${video_title[$i]}

" + echo "
${video_title[$i]}

" done \ No newline at end of file diff --git a/webroot/yt/watch.shs b/webroot/yt/watch.shs index 63cc10d..009a8d1 100755 --- a/webroot/yt/watch.shs +++ b/webroot/yt/watch.shs @@ -32,7 +32,7 @@ if [[ ${get_data[v]} ]]; then -

+

$title

@@ -60,6 +60,37 @@ if [[ ${get_data[v]} ]]; then
Description:
$(echo $video | jq -r '.description' | sed -E 's/$/
/g')
"; + + if [[ ${get_data[playlist]} ]]; then + playlist=$(youtube-dl -j --flat-playlist https://www.youtube.com/playlist?list=${get_data[playlist]}) + + IFS=$'\n' + video_title=($(jq -r '.title' <<< $playlist)) + video_id=($(jq -r '.id' <<< $playlist)) + + next='dQw4w9WgXcQ' + + for (( i=0; i<${#video_id[@]}; i++ )); do + if [[ ${video_id[$i]} == ${get_data[v]} ]]; then + next=${video_id[$((i+1))]} + break + fi + done + + echo "

Playlist

" + + for (( i=0; i<${#video_id[@]}; i++ )); do + echo "
${video_title[$i]}

" + done + fi else source templates/head.sh echo "pls add ?v param i'm still WiP"