#!/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 title=$(jq -r '.title' <<< $data) if [[ ${cfg[template]} == 'default' ]]; then meta[title]="$title" source templates/head.sh 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)) 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 source "${cfg[namespace]}/templates/header.shs" render strings "${cfg[namespace]}/templates/themes/${cfg[template]}/channel.t"