2020-07-16 23:10:31 +02:00
|
|
|
#!/bin/bash
|
2021-02-18 01:17:09 +01:00
|
|
|
|
2021-02-28 17:55:49 +01:00
|
|
|
declare -A strings
|
|
|
|
|
2021-02-18 01:17:09 +01:00
|
|
|
if [[ "${params[id]}" ]]; then
|
2021-03-30 23:22:16 +02:00
|
|
|
data=$(haruhi-dl --ie-key YoutubeChannel -J --flat-playlist "https://www.youtube.com/channel/${params[id]}")
|
2021-02-18 01:17:09 +01:00
|
|
|
elif [[ "${params[user]}" ]]; then
|
2021-03-30 23:22:16 +02:00
|
|
|
data=$(haruhi-dl --ie-key YoutubeChannel -J --flat-playlist "https://www.youtube.com/user/${params[user]}")
|
|
|
|
elif [[ "${params[c]}" ]]; then
|
|
|
|
data=$(haruhi-dl --ie-key YoutubeChannel -J --flat-playlist "https://www.youtube.com/c/${params[c]}")
|
2021-02-18 01:17:09 +01:00
|
|
|
elif [[ "${get_data[id]}" ]]; then
|
2021-03-30 23:22:16 +02:00
|
|
|
data=$(haruhi-dl --ie-key YoutubeChannel -J --flat-playlist "https://www.youtube.com/channel/${get_data[id]}")
|
2021-02-18 01:17:09 +01:00
|
|
|
elif [[ "${get_data[name]}" ]]; then
|
2021-03-30 23:22:16 +02:00
|
|
|
data=$(haruhi-dl --ie-key YoutubeChannel -J --flat-playlist "https://www.youtube.com/user/${get_data[name]}")
|
2020-07-16 23:10:31 +02:00
|
|
|
else
|
2020-11-08 02:51:59 +01:00
|
|
|
echo "Please specify either id or name"
|
2020-07-16 23:10:31 +02:00
|
|
|
return
|
|
|
|
fi
|
2021-03-14 15:43:17 +01:00
|
|
|
|
2020-12-29 05:56:44 +01:00
|
|
|
title=$(jq -r '.title' <<< $data)
|
|
|
|
|
2021-02-28 17:55:49 +01:00
|
|
|
if [[ ${cfg[template]} == 'default' ]]; then
|
|
|
|
meta[title]="$title"
|
|
|
|
source templates/head.sh
|
|
|
|
fi
|
2020-07-16 23:10:31 +02:00
|
|
|
|
|
|
|
IFS=$'\n'
|
2020-12-29 05:56:44 +01:00
|
|
|
video_title=($(jq -r '.entries[].title' <<< $data))
|
|
|
|
video_id=($(jq -r '.entries[].id' <<< $data))
|
2020-07-16 23:10:31 +02:00
|
|
|
|
2021-07-01 20:05:09 +02:00
|
|
|
#strings[subscribe]="<h1>$title</h1><a href='subscribe.shs?id=$(html_encode "${get_data[id]}")'>Subscribe!</a><br>"
|
|
|
|
strings[subscribe]='<h1>'"$(html_encode "$title")'s channel"'</h1>'
|
|
|
|
echo uwu > /dev/stderr
|
2021-03-14 15:43:17 +01:00
|
|
|
for (( i=0; i<${#video_id[@]}; i++ )); do
|
2021-02-28 17:55:49 +01:00
|
|
|
strings[videos]+="<a href='/watch?v=${video_id[$i]}'><img src='http://i.ytimg.com/vi/${video_id[$i]}/mqdefault.jpg'><br>${video_title[$i]}</a><br>"
|
2020-12-29 05:56:44 +01:00
|
|
|
done
|
2021-02-28 17:55:49 +01:00
|
|
|
|
2021-03-14 15:43:17 +01:00
|
|
|
if [[ ! ${strings[videos]} ]]; then
|
|
|
|
strings[videos]="Failed to fetch videos or channel does not have videos"
|
|
|
|
fi
|
|
|
|
|
2021-03-01 23:53:15 +01:00
|
|
|
source "${cfg[namespace]}/templates/header.shs"
|
2021-02-28 17:55:49 +01:00
|
|
|
render_unsafe strings "${cfg[namespace]}/templates/themes/${cfg[template]}/channel.t"
|