@phenomlab Perfect!!! Many thanks.
Pulling YouTube videos using RSS
-
I wanted a way to pull videos from YouTube, but have it so that
nodebb-plugin-rss
did all the heavy lifting, and I only had to provide the RSS. Simple? In theory, yes. In practice? No.YouTube for a number of years has hidden an RSS link in each channel it hosts, which previously could be used for that exact purpose - an RSS reader - and in our case, the RSS plugin we want to use. However, over time, and because of the ever-increasing monetisation prospects of the platform, the ability to read and parse these feeds has become problematic to say the least.
In most cases, they work fine in a browser
But when you try to pull them from the RSS plugin
Note the 404 status code. This is happening because the RSS plugin (to my knowledge) does not send an agent string to identify the browser type, and as a result, YouTube sees it as a bot and will reject the request.
The workaround here is to use a utility called RSSHub
https://docs.rsshub.app/routes/social-media#youtube
Essentially, we can leverage the free API of this site to provide a URL that the RSS plugin can work with.
How this works
- We visit the YouTube channel in question
- Right click anywhere there is a blank area on the page, and from the resulting window, choose “View Source”
- This then opens a new tab where we can see the underlying code.
- In this new tab, press F3 on your keyboard which should open the “find” utility
- In the search window, type RSS and press enter
- You should be able to find something the like the below
- Copy the RSS URL - in this case, it’s the below, but only the actual URL highlighted
- Now we just need to convert the link above, and append the channel ID after the = sign
- The link you land up with becomes
https://rsshub.app/youtube/channel/UCnr_M7_nAku9k3T88A4Ke2Q
- Copy that link and paste it into the RSS plugin testing area
- This new link should now return data
You can now use that same link in the RSS plugin to pull the videos you want
Considerations
This is a free API, so will be subject to fair usage policies. For this reason, I strongly recommend you check once per day to keep the session count low, and to prevent RSSHub from blocking your IP.
Bearing in mind the busiest of YouTube channels typically upload content at minimum daily, so this should be fine.
Enjoy.
-
That is awesome! What a great way to get relevant videos automatically without having to search for them every single day.
-
@Madchatthew Yes, exactly. The only real issue with this is using a foreign API, but they also have working code for X (Twitter), Instagram, LinkedIn, and many others. I do expect that they will enforce limits on their API, but it’s a brilliant service they are offering.
-
@phenomlab Yes and this goes along with what a lot of articles and youtube videos about programing are saying in regard to find a problem out in the world and come up with a solution. By doing that your chances of success are far greater than just coming up with something random. It seems to me that is what this RSS site has done. Maybe if it has been done before, then find a way to do it better.
-
The perfect solution and walkthrough Mark, appreciated as always!
Related Topics
-
Test of youtube embeds
Solved Configure -
-
-
-
-
Category For User
Solved Configure -
-