#!/bin/bash playlistURL="$1" noItems="$2" set -e playlistJSON=`youtube-dl "$playlistURL" --flat-playlist -J --playlist-end "$noItems"` uploader=`echo "$playlistJSON" | jq -r '.uploader'` if [ "$uploader" = "null" ]; then playlistJSON=`youtube-dl "$playlistURL" --flat-playlist -J --playlist-end "$noItems"` uploader=`echo "$playlistJSON" | jq -r '.uploader'` if [ "$uploader" = "null" ]; then exit 1 fi fi echo " <![CDATA[ $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 " "