2020-10-31 17:14:51 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
playlistURL="$1"
|
2020-10-31 19:04:21 +01:00
|
|
|
noItems="$2"
|
2020-10-31 17:14:51 +01:00
|
|
|
|
2020-11-01 12:24:45 +01:00
|
|
|
set -e
|
|
|
|
|
2020-10-31 18:28:22 +01:00
|
|
|
playlistJSON=`youtube-dl "$playlistURL" --flat-playlist -J --playlist-end "$noItems"`
|
2020-10-31 17:14:51 +01:00
|
|
|
uploader=`echo "$playlistJSON" | jq -r '.uploader'`
|
|
|
|
|
2020-11-01 20:38:45 +01:00
|
|
|
if [ "$uploader" = "null" ]; then
|
2020-11-09 21:05:01 +01:00
|
|
|
exit 1
|
2020-11-01 20:38:45 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2020-10-31 17:14:51 +01:00
|
|
|
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
|
|
|
<rss version=\"2.0\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\">
|
|
|
|
<channel>
|
2020-10-31 18:04:26 +01:00
|
|
|
<title><![CDATA[ $uploader ]]></title>
|
|
|
|
<link><![CDATA[ $playlistURL ]]></link>
|
|
|
|
<description><![CDATA[ $uploader ]]></description>
|
2020-10-31 17:14:51 +01:00
|
|
|
"
|
|
|
|
|
|
|
|
entries=`echo "$playlistJSON" | jq -r '.entries[] | .url + " " + .title'`
|
|
|
|
|
|
|
|
pubdate=`date --rfc-email`
|
|
|
|
|
|
|
|
echo "$entries" | while read entry; do
|
|
|
|
url=`echo "$entry" | cut -d' ' -f1`
|
|
|
|
title=`echo "$entry" | cut -d' ' -f2-`
|
|
|
|
pubdate=`date --rfc-email -d "$pubdate - 5 seconds"`
|
|
|
|
embedURL="https://www.youtube.com/embed/$url"
|
|
|
|
link="https://www.youtube.com/watch?v=$url"
|
|
|
|
echo "
|
|
|
|
<item>
|
|
|
|
<title><![CDATA[ $title ]]></title>
|
|
|
|
<content:encoded><![CDATA[ <iframe src=\"$embedURL\" allowfullscreen /> ]]></content:encoded>
|
|
|
|
<guid>$link</guid>
|
|
|
|
<link>$link</link>
|
|
|
|
<pubDate>$pubdate</pubDate>
|
|
|
|
</item>
|
|
|
|
"
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "
|
|
|
|
</channel>
|
|
|
|
</rss>
|
|
|
|
"
|