+ routes for most common YT endpoints

18l-fix
Dominika Liberda 2021-02-18 01:17:09 +01:00
parent a93b71fbae
commit b01b116854
3 changed files with 20 additions and 8 deletions

7
routes.sh Normal file
View File

@ -0,0 +1,7 @@
#router "/profile/:user" "app/webroot/index.shs"
#router "/uwu" "owo"
router "/watch" "${cfg[namespace]}/webroot/watch.shs"
router "/channel/:id" "${cfg[namespace]}/webroot/channel.shs"
router "/user/:user" "${cfg[namespace]}/webroot/channel.shs"
router "/playlist" "${cfg[namespace]}/webroot/playlist.shs"

View File

@ -1,7 +1,12 @@
#!/bin/bash
if [[ ${get_data[id]} ]]; then
if [[ "${params[id]}" ]]; then
data=$(haruhi-dl -J --flat-playlist "https://www.youtube.com/channel/${params[id]}")
elif [[ "${params[user]}" ]]; then
data=$(haruhi-dl -J --flat-playlist "https://www.youtube.com/user/${params[user]}")
elif [[ "${get_data[id]}" ]]; then
data=$(haruhi-dl -J --flat-playlist "https://www.youtube.com/channel/${get_data[id]}")
elif [[ ${get_data[name]} ]]; then
elif [[ "${get_data[name]}" ]]; then
data=$(haruhi-dl -J --flat-playlist "https://www.youtube.com/user/${get_data[name]}")
else
echo "Please specify either id or name"

View File

@ -1,10 +1,10 @@
#!/bin/bash
title=$(curl https://www.youtube.com/feeds/videos.xml?playlist_id=${get_data[id]} | grep title | head -n 1 | sed -s 's/ <title>//;s/<\/title>//')
meta[title]=$title
title=$(curl -s "https://www.youtube.com/feeds/videos.xml?playlist_id=${get_data[list]}" | grep title | head -n 1 | sed -s 's/ <title>//;s/<\/title>//')
meta[title]="$title"
source templates/head.sh
if [[ ${get_data[id]} ]]; then
data=$(haruhi-dl $([[ ${cfg[_cookies]} != "" ]] && echo -n -- "-c ${cfg[_cookies]}") -j --flat-playlist https://www.youtube.com/playlist?list=${get_data[id]})
if [[ "${get_data[list]}" ]]; then
data=$(haruhi-dl $([[ ${cfg[_cookies]} != "" ]] && echo -n -- "-c ${cfg[_cookies]}") -j --flat-playlist "https://www.youtube.com/playlist?list=${get_data[list]}")
else
echo "Please specify id"
return
@ -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 "<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
echo "<a href='watch.shs?v=${video_id[$i]}&playlist=$(html_encode "${get_data[list]}")'><img src='https://i.ytimg.com/vi/${video_id[$i]}/mqdefault.jpg'><br>${video_title[$i]}</a><br>"
done