Martijn has Bear

Find YouTube RSS feed URLs with yt-dlp

I subscribe to YouTube channels first on YouTube (to contribute to the creator’s subscriber count) and then through my feed reader of choice. This way I am consistently told about the latest videos, in chronological order.

How to get the feed URLs is a constant question. Today I tried to solve it with nothing but another favourite tool of mine: yt-dlp.

yt-dlp --simulate \
       --no-warnings \
       --use-extractors "youtube:tab,youtube" \
       --extractor-args "youtube:player-client=web" \
       --flat-playlist \
       --playlist-items 0 \
       --print playlist:'Channel feed: https://www.youtube.com/feeds/videos.xml?channel_id=%(channel_id)s' \
       --print playlist:'Playlist feed: https://www.youtube.com/feeds/videos.xml?playlist_id=%(id)s' \
       --print video:'Channel feed: https://www.youtube.com/feeds/videos.xml?channel_id=%(channel_id)s' \
       "https://www.youtube.com/watch?v=i3PKORt9Vls&list=PLS3XGZxi7cBUrUJCogORjjD1tZFyR7YS9&index=2&pp=iAQB"

Running that command will output the following:

Channel feed: https://www.youtube.com/feeds/videos.xml?channel_id=UC16niRr50-MSBwiO3YDb3RA
Playlist feed: https://www.youtube.com/feeds/videos.xml?playlist_id=PLS3XGZxi7cBUrUJCogORjjD1tZFyR7YS9

Those are the two feeds associated with the video. First is the RSS feed for the entire channel that posted the video (BBC News) and the second for the playlist the video was watched from (Gaming | BBC News).

Just swap out the video link at the end of the command to get feed URLs for anything else. I have tested it with links to videos, links to playlists, and links to channels. I expect it will except many other YouTube links.

One known bug: the output identifies links to channels is if they are links to playlists and will result in a broken playlist feed. This should not matter as you should be grabbing the channel feed anyway:

Channel feed: https://www.youtube.com/feeds/videos.xml?channel_id=UC16niRr50-MSBwiO3YDb3RA
Playlist feed: https://www.youtube.com/feeds/videos.xml?playlist_id=@BBCNews