diff --git a/routes.sh b/routes.sh new file mode 100644 index 0000000..978097b --- /dev/null +++ b/routes.sh @@ -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" diff --git a/webroot/channel.shs b/webroot/channel.shs index c4bac65..5c0c541 100644 --- a/webroot/channel.shs +++ b/webroot/channel.shs @@ -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" diff --git a/webroot/playlist.shs b/webroot/playlist.shs index d210b15..11acc62 100644 --- a/webroot/playlist.shs +++ b/webroot/playlist.shs @@ -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/ //;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 \ No newline at end of file + 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