2020-07-16 23:10:31 +02:00
#!/bin/bash
2021-02-18 01:17:09 +01:00
title=$(curl -s "https://www.youtube.com/feeds/videos.xml?playlist_id=${get_data[list]}" | grep title | head -n 1 | sed -s 's/ <title>//;s/<\/title>//')
2021-02-28 17:43:40 +01:00
declare -A strings
if [[ ${cfg[template]} == 'default' ]]; then
meta[title]="$title"
source templates/head.sh
fi
2020-07-16 23:10:31 +02:00
2021-02-18 01:17:09 +01:00
if [[ "${get_data[list]}" ]]; then
2022-11-29 12:47:24 +01:00
data=$(yt-dlp --cookies ${cfg[_cookies]} -j --flat-playlist "https://www.youtube.com/playlist?list=${get_data[list]}")
2020-07-16 23:10:31 +02:00
else
2021-02-28 17:43:40 +01:00
strings[playlist]="Please specify id"
2020-07-16 23:10:31 +02:00
fi
IFS=$'\n'
video_title=($(jq -r '.title' <<< $data))
video_id=($(jq -r '.id' <<< $data))
2023-01-18 06:35:55 +01:00
nested_declare list
declare -A item
2020-07-16 23:10:31 +02:00
for (( i=0; i<${#video_id[@]}; i++ )); do
2023-01-18 06:35:55 +01:00
item[id]="${video_id[$i]}"
item[playlist]="${get_data[list]}"
item[title]="${video_title[$i]}"
nested_add list item
2021-02-18 01:17:09 +01:00
done
2021-02-28 17:43:40 +01:00
2023-01-18 06:35:55 +01:00
strings[_playlist]="list"
2021-03-14 15:43:17 +01:00
2021-03-01 23:53:15 +01:00
source "${cfg[namespace]}/templates/header.shs"
2023-01-18 06:35:55 +01:00
render strings "${cfg[namespace]}/templates/themes/${cfg[template]}/playlist.html"