2020-07-16 23:10:31 +02:00
|
|
|
#!/bin/bash
|
2021-02-18 01:17:09 +01:00
|
|
|
|
2021-02-28 17:55:49 +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]}")
|
2021-03-30 23:22:16 +02:00
|
|
|
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]}")
|
2020-07-16 23:10:31 +02:00
|
|
|
else
|
2020-11-08 02:51:59 +01:00
|
|
|
echo "Please specify either id or name"
|
2020-07-16 23:10:31 +02:00
|
|
|
return
|
|
|
|
fi
|
2021-03-14 15:43:17 +01:00
|
|
|
|
2023-04-21 15:07:20 +02:00
|
|
|
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.shs___id=${get_data[id]}"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
strings[?suberror]=true
|
|
|
|
fi
|
|
|
|
|
2020-12-29 05:56:44 +01:00
|
|
|
title=$(jq -r '.title' <<< $data)
|
|
|
|
|
2023-04-19 22:42:30 +02:00
|
|
|
if [[ ${cfg[template]} != 'retro' ]]; then
|
2021-02-28 17:55:49 +01:00
|
|
|
meta[title]="$title"
|
2023-04-19 22:42:30 +02:00
|
|
|
#source templates/head.sh
|
|
|
|
source "${cfg[namespace]}/templates/header.shs"
|
2021-02-28 17:55:49 +01:00
|
|
|
fi
|
2020-07-16 23:10:31 +02:00
|
|
|
|
|
|
|
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))
|
2020-07-16 23:10:31 +02:00
|
|
|
|
2023-04-21 15:07:20 +02:00
|
|
|
strings[subscribe]="$(html_encode "$title" | sed -E "s/ - Videos//g")"
|
2022-11-29 08:58:28 +01:00
|
|
|
|
|
|
|
nested_declare meow
|
|
|
|
declare -A nyaa
|
2021-03-14 15:43:17 +01:00
|
|
|
for (( i=0; i<${#video_id[@]}; i++ )); do
|
2022-11-29 08:58:28 +01:00
|
|
|
nyaa[id]="${video_id[$i]}"
|
|
|
|
nyaa[title]="${video_title[$i]}"
|
|
|
|
|
|
|
|
nested_add meow nyaa
|
2020-12-29 05:56:44 +01:00
|
|
|
done
|
2022-11-29 08:58:28 +01:00
|
|
|
strings[_videos]+="meow"
|
2021-02-28 17:55:49 +01:00
|
|
|
|
2022-11-29 08:58:28 +01:00
|
|
|
nested_get meow 0
|
|
|
|
strings[err]=''
|
|
|
|
if [[ "${res[id]}" == '' ]]; then
|
2023-04-21 15:07:20 +02:00
|
|
|
strings[err]="Failed to fetch videos... :c"
|
2021-03-14 15:43:17 +01:00
|
|
|
fi
|
|
|
|
|
2023-01-18 01:08:05 +01:00
|
|
|
render strings "${cfg[namespace]}/templates/themes/${cfg[template]}/channel.html"
|