bashtube/webroot/channel.shs

51 lines
1.5 KiB
Plaintext
Raw Normal View History

#!/bin/bash
2021-02-18 01:17:09 +01:00
declare -A strings
2021-02-18 01:17:09 +01:00
if [[ "${params[id]}" ]]; then
2022-06-21 02:21:08 +02:00
data=$(yt-dlp -J --flat-playlist "https://www.youtube.com/channel/${params[id]}")
2021-02-18 01:17:09 +01:00
elif [[ "${params[user]}" ]]; then
2022-06-21 02:21:08 +02:00
data=$(yt-dlp -J --flat-playlist "https://www.youtube.com/user/${params[user]}")
elif [[ "${params[c]}" ]]; then
2022-06-21 02:21:08 +02:00
data=$(yt-dlp -J --flat-playlist "https://www.youtube.com/c/${params[c]}")
2021-02-18 01:17:09 +01:00
elif [[ "${get_data[id]}" ]]; then
2022-06-21 02:21:08 +02:00
data=$(yt-dlp -J --flat-playlist "https://www.youtube.com/channel/${get_data[id]}")
2021-02-18 01:17:09 +01:00
elif [[ "${get_data[name]}" ]]; then
2022-06-21 02:21:08 +02:00
data=$(yt-dlp -J --flat-playlist "https://www.youtube.com/user/${get_data[name]}")
else
2020-11-08 02:51:59 +01:00
echo "Please specify either id or name"
return
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'
2022-12-05 12:13:59 +01:00
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")"
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"