bashtube/webroot/playlist.shs
4 raccoons in a trenchcoat. / luna vivian d0ef4a9e55 overhauled playlist page
fixes issue #7

A new playlist view UI!

It now is more in line with the ones in these following pages:
- global faves (home page)
- Your Feed
- Your favourites
- Search

It has the same 3-column grid you love from the other pages already. c:
It also now displays the playlist title at the top of it.
2023-04-20 02:53:11 +02:00

39 lines
1 KiB
Bash

#!/bin/bash
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>//')
declare -A strings
if [[ "${get_data[list]}" ]]; then
strings[playlistname]="$title"
strings[?playlist]=true
fi
if [[ ${cfg[template]} != 'retro' ]]; then
meta[title]="$title"
#source templates/head.sh
source "${cfg[namespace]}/templates/header.shs"
fi
if [[ "${get_data[list]}" ]]; then
data=$(yt-dlp --cookies ${cfg[_cookies]} -j --flat-playlist "https://www.youtube.com/playlist?list=${get_data[list]}")
else
strings[playlist]="Please specify an ID"
fi
IFS=$'\n'
video_title=($(jq -r '.title' <<< $data))
video_id=($(jq -r '.id' <<< $data))
nested_declare list
declare -A item
for (( i=0; i<${#video_id[@]}; i++ )); do
item[id]="${video_id[$i]}"
item[playlist]="${get_data[list]}"
item[title]="${video_title[$i]}"
nested_add list item
done
strings[_playlist]="list"
render strings "${cfg[namespace]}/templates/themes/${cfg[template]}/playlist.html"