Skip to content

Instantly share code, notes, and snippets.

@Coool
Forked from tjluoma/youtube-rss.sh
Created December 29, 2020 14:46
Show Gist options
  • Select an option

  • Save Coool/66a2c9272011e4618dc832e2b9a6f705 to your computer and use it in GitHub Desktop.

Select an option

Save Coool/66a2c9272011e4618dc832e2b9a6f705 to your computer and use it in GitHub Desktop.
Did you know YouTube has RSS feeds? No? Probably because YouTube makes them nearly impossible to find. But here's an easy way to get the RSS feed for any YouTube user. Based on <https://eggfreckles.net/2020/01/03/youtube-rss/>
#!/usr/bin/env zsh -f
# Purpose: get the RSS feed for a YouTube page
# Inspired By: https://eggfreckles.net/2020/01/03/youtube-rss/
#
# From: Timothy J. Luoma
# Mail: luomat at gmail dot com
# Date: 2020-01-17
NAME="$0:t:r"
if [[ -e "$HOME/.path" ]]
then
source "$HOME/.path"
else
PATH="$HOME/scripts:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin"
fi
for i in "$@"
do
CHANNEL_ID=$(curl -sfLS "$i" | fgrep -i '<meta itemprop="channelId" ' | awk -F'"' '//{print $4}')
if [[ "$CHANNEL_ID" == "" ]]
then
echo "$NAME: no channel ID found for '$i'." >>/dev/stderr
else
echo "https://www.youtube.com/feeds/videos.xml?channel_id=${CHANNEL_ID}"
# copy URL to clipboard
echo -n "https://www.youtube.com/feeds/videos.xml?channel_id=${CHANNEL_ID}" | pbcopy
fi
done
exit 0
#EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment