autoplay on videos (playlist only, will make it nicer later), playlist videos now automatically forward to the next one
This commit is contained in:
parent
eb3b76b46f
commit
90990f5928
|
@ -15,5 +15,5 @@ video_title=($(jq -r '.title' <<< $data))
|
||||||
video_id=($(jq -r '.id' <<< $data))
|
video_id=($(jq -r '.id' <<< $data))
|
||||||
|
|
||||||
for (( i=0; i<${#video_id[@]}; i++ )); do
|
for (( i=0; i<${#video_id[@]}; i++ )); do
|
||||||
echo "<a href='watch.shs?v=${video_id[$i]}'><img src='http://i.ytimg.com/vi/${video_id[$i]}/mqdefault.jpg'><br>${video_title[$i]}</a><br>"
|
echo "<a href='watch.shs?v=${video_id[$i]}&playlist=${get_data[id]}'><img src='http://i.ytimg.com/vi/${video_id[$i]}/mqdefault.jpg'><br>${video_title[$i]}</a><br>"
|
||||||
done
|
done
|
|
@ -32,7 +32,7 @@ if [[ ${get_data[v]} ]]; then
|
||||||
<input name='q' type='text'>
|
<input name='q' type='text'>
|
||||||
<input type='submit' value='Search'>
|
<input type='submit' value='Search'>
|
||||||
</form>
|
</form>
|
||||||
<div><br><video src='$url' controls></video>
|
<div><br><video id='player' src='$url' controls></video>
|
||||||
<h2>$title</h2>
|
<h2>$title</h2>
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
|
@ -60,6 +60,37 @@ if [[ ${get_data[v]} ]]; then
|
||||||
</div>
|
</div>
|
||||||
<span><i>Description</i>:<br>$(echo $video | jq -r '.description' | sed -E 's/$/<br>/g')</span>
|
<span><i>Description</i>:<br>$(echo $video | jq -r '.description' | sed -E 's/$/<br>/g')</span>
|
||||||
</div>";
|
</div>";
|
||||||
|
|
||||||
|
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 "<script type='text/javascript'>
|
||||||
|
window.addEventListener('DOMContentLoaded', (event) => {
|
||||||
|
var video = document.getElementById('player');
|
||||||
|
video.play();
|
||||||
|
video.addEventListener('ended',function(){
|
||||||
|
window.location = 'watch.shs?v=$next&playlist=${get_data[playlist]}';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script><h1>Playlist</h1>"
|
||||||
|
|
||||||
|
for (( i=0; i<${#video_id[@]}; i++ )); do
|
||||||
|
echo "<a href='watch.shs?v=${video_id[$i]}&playlist=${get_data[playlist]}'><img src='http://i.ytimg.com/vi/${video_id[$i]}/mqdefault.jpg'><br>${video_title[$i]}</a><br>"
|
||||||
|
done
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
source templates/head.sh
|
source templates/head.sh
|
||||||
echo "pls add ?v param i'm still WiP"
|
echo "pls add ?v param i'm still WiP"
|
||||||
|
|
Loading…
Reference in a new issue