Hi, I’m Erika Rowland (a.k.a. erikareads). Hi, I’m Erika. I’m an Ops-shaped Software Engineer, Toolmaker, and Resilience Engineering fan. I like Elixir and Gleam, Reading, and Design. She/Her. Constellation Webring Published on

YouTube RSS Feeds

I’m trying to get back into using RSS feeds. YouTube used to make it easy to follow channels by RSS, but they’ve removed that ease in favor of what seems to be channeling you into creating a Google account.

YouTube feeds do still generate an RSS feed though. It can be found at:

https://www.youtube.com/feeds/videos.xml?channel_id=<channel_id>

Where <channel_id> is replaced with the identifier for the YouTube channel you want to follow. However, YouTube no longer uses these channel ids in the channel URL, phasing them out in favor of @ style handles for each channel. This leads to easier to remember links to channels, but that @-handle doesn’t work in the feeds link above.

I found that this channel id was still available under the “share” arrow on the “About” page for a channel.

I was talking to my friend Jeff, and we decided to see if we could do something about this manual process of navigating to the “About” page and clicking the share arrow.

The Search is On

My first thought was to open the browser DevTools on the About page. Here I used the inspector to find the HTML for the share arrow. This didn’t lead far, as the arrow is powered by javascript. I didn’t know how to search the javascript for the HTML class, since javascript is often split up across multiple files.

After a web search I found a ChromeI usually browse with Firefox, but Jeff was more familiar with the Chrome DevTools. I haven’t determined if there is an equivalent “search everything” for Firefox DevTools. DevTools help article: Search: Find text across all loaded resources.

Here, I meant to search for the HTML class, but I accidentally pasted the clipboarded channel-id.

Turns out it was right there in the HTMLThis is the channel-id for the @charmcli youtube channel.:

<meta itemprop="identifier" content="UCTVHQ9GMFYLalQDynyXNTKQ">

Parsing HTML

I wanted to create a script that would take a channel’s @-handle, and copy the resulting RSS link to my clipboard so I could use it in my RSS reader.

Fetching the HTML was easy enough:

$ curl https://www.youtube.com/@charmcli/about
<wall of html>

Now I needed a way to select out the channel-id from the HTML tags. Enter pup.

pup is a command line HTML parser. I could pipe the HTML from curl into pup to select all meta tags:

$ curl https://www.youtube.com/@charmcli/about \ 
> | pup 'meta'
<only meta tags>

I wanted to then select a specific tag based on a property:

$ curl https://www.youtube.com/@charmcli/about \
> | pup 'meta[itemprop="identifier"]'
<meta itemprop="identifier" content="UCTVHQ9GMFYLalQDynyXNTKQ">

Finally, pup provides an attr function to select from an attribute, in this case content:

$ curl https://www.youtube.com/@charmcli/about \
> | pup 'meta[itemprop="identifier"] attr{content}'
UCTVHQ9GMFYLalQDynyXNTKQ

All together

The final script looks like this:

channel_id=$(curl https://www.youtube.com/$1/about | pup 'meta[itemprop="identifier"] attr{content}')
echo -n "https://www.youtube.com/feeds/videos.xml?channel_id=$channel_id" | xclip -selection clipboard

Now I can follow my favorite YouTube channels from my RSS reader!


Constellation Webring