Add channel template (+ fix /issues/8 i guess)

18l-fix
sech1p 2021-02-28 17:55:49 +01:00
parent 89feca7ae8
commit 16cbc44a5a
2 changed files with 12 additions and 4 deletions

View File

@ -0,0 +1,2 @@
{{.subscribe}}
{{.videos}}

View File

@ -1,5 +1,7 @@
#!/bin/bash
declare -A strings
if [[ "${params[id]}" ]]; then
data=$(haruhi-dl -J --flat-playlist "https://www.youtube.com/channel/${params[id]}")
elif [[ "${params[user]}" ]]; then
@ -14,15 +16,19 @@ else
fi
title=$(jq -r '.title' <<< $data)
meta[title]="$title"
source templates/head.sh
if [[ ${cfg[template]} == 'default' ]]; then
meta[title]="$title"
source templates/head.sh
fi
IFS=$'\n'
video_title=($(jq -r '.entries[].title' <<< $data))
video_id=($(jq -r '.entries[].id' <<< $data))
echo "<h1>$title</h1><a href='subscribe.shs?id=$(html_encode "${get_data[id]}")'>Subscribe!</a><br>"
strings[subscribe]="<h1>$title</h1><a href='subscribe.shs?id=$(html_encode "${get_data[id]}")'>Subscribe!</a><br>"
for (( i=0; i<${#video_id[@]}; i++ )); do
echo "<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>"
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>"
done
render_unsafe strings "${cfg[namespace]}/templates/themes/${cfg[template]}/channel.t"