579795d83f
- 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!)
87 lines
2.6 KiB
Bash
87 lines
2.6 KiB
Bash
#!/bin/bash
|
|
|
|
declare -A strings
|
|
|
|
if [[ "${params[id]}" ]]; then
|
|
data=$(yt-dlp -J --flat-playlist "https://www.youtube.com/channel/${params[id]}")
|
|
elif [[ "${params[user]}" ]]; then
|
|
data=$(yt-dlp -J --flat-playlist "https://www.youtube.com/user/${params[user]}")
|
|
elif [[ "${params[c]}" ]]; then
|
|
data=$(yt-dlp -J --flat-playlist "https://www.youtube.com/c/${params[c]}")
|
|
elif [[ "${get_data[id]}" ]]; then
|
|
data=$(yt-dlp -J --flat-playlist "https://www.youtube.com/channel/${get_data[id]}")
|
|
elif [[ "${get_data[name]}" ]]; then
|
|
data=$(yt-dlp -J --flat-playlist "https://www.youtube.com/user/${get_data[name]}")
|
|
else
|
|
echo "Please specify either id or name"
|
|
return
|
|
fi
|
|
|
|
if [[ "${get_data[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]="${get_data[id]}"
|
|
else
|
|
strings[?unsub]=true
|
|
strings[channel_id]="${get_data[id]}"
|
|
fi
|
|
else
|
|
strings[?login]=true
|
|
#strings[login_r]=$(sed -s 's/?/___/' <<< "${r[url]}")
|
|
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
|
|
fi
|
|
#else
|
|
#strings[?suberror]=true
|
|
#fi
|
|
|
|
title=$(jq -r '.title' <<< $data)
|
|
|
|
if [[ ${cfg[template]} != 'retro' ]]; then
|
|
meta[title]="$title"
|
|
#source templates/head.sh
|
|
source "${cfg[namespace]}/templates/header.shs"
|
|
fi
|
|
|
|
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))
|
|
|
|
if [[ $title != 'null' ]]; then
|
|
strings[?cnnc]=true
|
|
strings[subscribe]="$(html_encode "$title" | sed -E "s/ - Videos//g")"
|
|
fi
|
|
|
|
nested_declare meow
|
|
declare -A nyaa
|
|
for (( i=0; i<${#video_id[@]}; i++ )); do
|
|
nyaa[id]="${video_id[$i]}"
|
|
nyaa[title]="${video_title[$i]}"
|
|
|
|
nested_add meow nyaa
|
|
done
|
|
strings[_videos]+="meow"
|
|
|
|
nested_get meow 0
|
|
strings[err]=''
|
|
if [[ "${res[id]}" == '' ]]; then
|
|
strings[err]="Failed to fetch videos."
|
|
fi
|
|
|
|
render strings "${cfg[namespace]}/templates/themes/${cfg[template]}/channel.html"
|