fixed some stuff™ in /channel page

- Subscribe links: /channel/{CHANNEL_ID} links work now!
- Channel name now gets hidden when it fails to fetch videos
(- now also hiding verbose error handling text!)
merge-requests/6/head
4 raccoons in a trenchcoat. / luna vivian 2023-04-21 15:40:11 +02:00
parent 64f49a3461
commit 579795d83f
2 changed files with 24 additions and 6 deletions

View File

@ -1,4 +1,4 @@
<h1>Channel "{{.subscribe}}"</h1>
{{start ?cnnc}}<h1>Channel "{{.subscribe}}"</h1>{{end ?cnnc}}
{{.err}}
{{start ?sub}}<a href='/subscribe.shs?id={{.channel_id}}' target='_blank'>Subscribe to {{.subscribe}}!</a><br><br>{{end ?sub}}
{{start ?unsub}}<a href='/unsubscribe.shs?id={{.channel_id}}' target='_blank' style="color:#d00;">Unsubscribe from {{.subscribe}}!</a><br><br>{{end ?unsub}}

View File

@ -29,11 +29,26 @@ if [[ "${get_data[id]}" ]]; then
else
strings[?login]=true
#strings[login_r]=$(sed -s 's/?/___/' <<< "${r[url]}")
strings[login_r]="channel.shs___id=${get_data[id]}"
strings[login_r]="channel/${get_data[id]}"
fi
elif [[ "${params[id]}" ]]; then
if [[ "${cookies[sh_session]}" != '' ]]; then
if [[ $(grep $(session_get_username "${cookies[sh_session]}") storage/subscribed | grep "${strings[channel_id]}") == '' ]]; then
strings[?sub]=true
strings[channel_id]="${params[id]}"
else
strings[?unsub]=true
strings[channel_id]="${params[id]}"
fi
else
strings[?login]=true
#strings[login_r]=$(sed -s 's/?/___/' <<< "${r[url]}")
strings[login_r]="channel/${params[id]}"
fi
else
strings[?suberror]=true
fi
#else
#strings[?suberror]=true
#fi
title=$(jq -r '.title' <<< $data)
@ -47,7 +62,10 @@ IFS=$'\n'
video_title=($(jq -r 'if .entries[].channel_follower_count != null then .entries[].entries[] else .entries[] end | .title' <<< $data))
video_id=($(jq -r 'if .entries[].channel_follower_count != null then .entries[].entries[] else .entries[] end | .id' <<< $data))
strings[subscribe]="$(html_encode "$title" | sed -E "s/ - Videos//g")"
if [[ $title != 'null' ]]; then
strings[?cnnc]=true
strings[subscribe]="$(html_encode "$title" | sed -E "s/ - Videos//g")"
fi
nested_declare meow
declare -A nyaa
@ -62,7 +80,7 @@ strings[_videos]+="meow"
nested_get meow 0
strings[err]=''
if [[ "${res[id]}" == '' ]]; then
strings[err]="Failed to fetch videos... :c"
strings[err]="Failed to fetch videos."
fi
render strings "${cfg[namespace]}/templates/themes/${cfg[template]}/channel.html"