Skip to content

Instantly share code, notes, and snippets.

@HarHarLinks
Created July 16, 2023 10:26
Show Gist options
  • Save HarHarLinks/aed649a4063dc1428e7fe0bc3a986cb2 to your computer and use it in GitHub Desktop.
Save HarHarLinks/aed649a4063dc1428e7fe0bc3a986cb2 to your computer and use it in GitHub Desktop.
run like `./get-youtube-channel-feed-url.sh https://www.youtube.com/channel/UCuAXFkgsw1L7xaCfnd5JJOw` which will return `https://www.youtube.com/feeds/videos.xml?channel_id=UCuAXFkgsw1L7xaCfnd5JJOw` which is an atom feed of the channel's videos
#!/usr/bin/env bash
if [[ ! -z "$1" ]];
then
channelid=$(curl --silent "$1" | grep "externalId" | sed -E 's/.+"externalId":"([[:alnum:]]+)".+/\1/')
if [[ ! -z "$channelid" ]];
then
echo -n "https://www.youtube.com/feeds/videos.xml?channel_id=$channelid"
echo ""
exit 0
fi
fi
echo "provide YouTube channel URL as argument"
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment