From 07d6c05fd66f3edcf66e9a1db46751b2f62bb0f1 Mon Sep 17 00:00:00 2001 From: gutmet Date: Sat, 31 Oct 2020 17:14:51 +0100 Subject: [PATCH] youtube-rss: generate an rss from a channel with youtube-dl, jq and GNU date --- youtube-rss | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 youtube-rss diff --git a/youtube-rss b/youtube-rss new file mode 100755 index 0000000..3c53c3b --- /dev/null +++ b/youtube-rss @@ -0,0 +1,40 @@ +#!/bin/bash + +playlistURL="$1" + +playlistJSON=`youtube-dl "$playlistURL" --flat-playlist -J` +uploader=`echo "$playlistJSON" | jq -r '.uploader'` + +echo " + + +$uploader +$playlistURL +$uploader +" + +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 " + + <![CDATA[ $title ]]> + ]]> + $link + $link + $pubdate + + " +done + +echo " + + +"