You can have it as a oneliner:
curl -s https://www.youtube.com/@CHANNEL | grep -Po '"canonical" href="https://www.youtube.com/channel/\K.*?(?=">)' | xargs -I@ echo 'https://www.youtube.com/feeds/videos.xml?channel_id=@'
youtube-rss-generator () {
CHANNEL_URL="$1"
if [[ -n "$CHANNEL_URL" ]]; then
curl -s "$CHANNEL_URL" | \
grep -Po '<link rel="canonical" href="https://www.youtube.com/channel/\K.*?(?=">)' | \
xargs -I@ echo 'https://www.youtube.com/feeds/videos.xml?channel_id=@'
else
echo "Usage: youtube-rss-generator https://www.youtube.com/path/to/channel"
fi
}
or as a command:
curl -s 'https://gist.githubusercontent.com/anio/6cc696ea375e879ba952d2c6b92f43f7/raw/b5d96349bbb9df7adb69315955b0b35f1284ee3a/youtube-rss-generator.sh' -o youtube-rss-generator.sh
chmod +x youtube-rss-generator.sh
sudo cp youtube-rss-generator.sh /usr/bin/youtube-rss-generator