Add friendly messages to template strings

18l-fix
sech1p 2021-03-14 15:43:17 +01:00
parent c4757e3657
commit ac879ac79d
8 changed files with 31 additions and 2 deletions

View File

@ -14,6 +14,7 @@ else
echo "Please specify either id or name"
return
fi
title=$(jq -r '.title' <<< $data)
if [[ ${cfg[template]} == 'default' ]]; then
@ -27,9 +28,13 @@ video_id=($(jq -r '.entries[].id' <<< $data))
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
for (( i=0; i<${#video_id[@]}; i++ )); do
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
if [[ ! ${strings[videos]} ]]; then
strings[videos]="Failed to fetch videos or channel does not have videos"
fi
source "${cfg[namespace]}/templates/header.shs"
render_unsafe strings "${cfg[namespace]}/templates/themes/${cfg[template]}/channel.t"

View File

@ -23,5 +23,9 @@ for i in $(tac storage/faves | grep -P "^$(session_get_username ${cookies[sh_ses
strings[fav]+="<div><a href='watch?v=${array[1]}'><img src='https://i.ytimg.com/vi/${array[1]}/mqdefault.jpg'><br><b>${array[@]:2:999}</b></a><br></div>";
done
if [[ ! ${strings[fav]} ]]; then
strings[fav]="You are not logged in or you do not have any favorites"
fi
source "${cfg[namespace]}/templates/header.shs"
render_unsafe strings "${cfg[namespace]}/templates/themes/${cfg[template]}/fav.t"

View File

@ -4,6 +4,8 @@ source ${cfg[namespace]}/templates/header.shs
declare -A strings
strings[favourites]="No favorite videos found,<br>you can do it first! ^w^"
IFS=$'\n'
for i in $(tac storage/faves); do
IFS=':'

View File

@ -22,5 +22,9 @@ for (( i=0; i<${#video_id[@]}; i++ )); do
strings[playlist]+="<a href='watch?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
if [[ ! ${strings[playlist]} ]]; then
strings[playlist]="Invalid playlist or playlist does not have videos"
fi
source "${cfg[namespace]}/templates/header.shs"
render_unsafe strings "${cfg[namespace]}/templates/themes/${cfg[template]}/playlist.t"

View File

@ -14,6 +14,8 @@ source templates/head.sh
if [[ $status == 1 && $reason != '' ]]; then
strings[reason]="$reason"
else
strings[reason]=""
fi
render strings "${cfg[namespace]}/templates/themes/${cfg[template]}/register.t"

View File

@ -29,7 +29,11 @@ if [[ "${get_data[q]}" ]]; then
strings[results]+="<a href='/watch?v=${id[$i]}'><img src='https://i.ytimg.com/vi/${id[$i]}/mqdefault.jpg'><br>${title[$i]}</a> | ${runtime[$i]} seconds | ${views[$i]} views<br>Uploaded by <a href='/channel/${channel_id[$i]}'>${channel[$i]}</a><br>"
done
else
echo "search for something will 'ya?"
strings[results]="search for something will 'ya?"
fi
if [[ ! $(which haruhi-dl) || $? != "0" ]]; then
strings[results]="Could not fetch search results"
fi
source "${cfg[namespace]}/templates/header.shs"

View File

@ -27,5 +27,9 @@ done
unset IFS
if [[ ! ${strings[subscribe]} ]]; then
strings[subscribe]="You are not logged in or you do not have any subscribed channels"
fi
source "${cfg[namespace]}/templates/header.shs"
render_unsafe strings "${cfg[namespace]}/templates/themes/${cfg[template]}/subscribe.t"

View File

@ -2,6 +2,10 @@
declare -A strings
if [[ ! $(which haruhi-dl) ]]; then
echo "Could not load video"
fi
if [[ "${get_data[v]}" ]]; then
if [[ "${get_data[v]}" == '18l' || "${get_data[v]}" == '5eFdt6Y_34E' ]]; then
strings[uploader]='MyMusicGroup'