Skip to content

Pulling YouTube videos using RSS

Configure
  • 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

    2b50f168-be41-4386-b56a-70dec17943af-image.png

    But when you try to pull them from the RSS plugin

    e5c976ed-17d6-4bf6-808d-711a988e1f0f-image.png

    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

    1. We visit the YouTube channel in question
    2. Right click anywhere there is a blank area on the page, and from the resulting window, choose “View Source”
      9c6f0d42-7ed9-44b5-95e4-327f01e67a12-image.png
    3. This then opens a new tab where we can see the underlying code.
    4. In this new tab, press F3 on your keyboard which should open the “find” utility
    5. In the search window, type RSS and press enter
    6. You should be able to find something the like the below
      865cf25f-4fb4-4ea3-9467-6f67fd9571f8-image.png
    7. Copy the RSS URL - in this case, it’s the below, but only the actual URL highlighted
      c61a647e-5acf-4833-9cd7-7b7b88c3b61b-image.png
    8. Now we just need to convert the link above, and append the channel ID after the = sign
    9. The link you land up with becomes https://rsshub.app/youtube/channel/UCnr_M7_nAku9k3T88A4Ke2Q
    10. Copy that link and paste it into the RSS plugin testing area
      47a72a92-2fa9-49f1-8a9e-0535086657f2-image.png
    11. This new link should now return data
      118fa96f-24b7-42cb-b5da-90409e4e5d60-image.png

    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
  • Opening links in nodebb widget

    Solved Configure
    6
    4 Votes
    6 Posts
    133 Views

    A more efficient way of including this would be to not over complicate it and leverage a standard iframe (providing the CSP headers of the remote site permit this) like below

    <iframe src="https://www.classmarker.com/online-test/start/?quiz=gag66aea7922f0a5" width="700" height="800"></iframe>

    This works first time every time on your site as intended.

  • Test of youtube embeds

    Solved Configure
    5
    3 Votes
    5 Posts
    80 Views

    @Madchatthew no, you just need to be in NodeBB root

  • 15 Votes
    14 Posts
    247 Views

    @phenomlab said in What's your view on RSS - is it dead technology?:

    @JAC would be keen to get your views around RSS feeds

    I’ve used RSS feeds over the years to pull in articles on forums and websites. I also have an RSS feed app on my phone that contains selective football news, it’s still an incredibly handful tool for me.

  • MogoDB v6 to v7 upgrade

    Solved Configure
    5
    1 Votes
    5 Posts
    448 Views

    @Panda if you used the Ubuntu PPA, I think this only goes as far as 6.x if I recall correctly.

  • How to deploy WordPress.org Developer theme

    Solved Configure
    4
    1 Votes
    4 Posts
    373 Views

    @Hari the real issue here is that I don’t think it can be used as a theme for WordPress because of the dependencies it clearly has, including its own Web server.

    My view here is that this is designed to be a complete development environment outside of the WordPress core.

  • Category For User

    Solved Configure
    11
    12 Votes
    11 Posts
    467 Views

    3.5.1 has now been released. I’ve just deployed it, so safe to do so!

  • how to use CF tunnels with Virtualmin?

    Solved Configure
    10
    3 Votes
    10 Posts
    965 Views

    @Hari DDoS protection is not just a switch, or one component. It’s a collection of different and often disparate technologies that when grouped together form the basis of a combined toolset that can be used in defence.

    Typically these consist of IDS (Instrusion Detection System) and IPS (Intrusion Prevention System) components that detect irregularities in network traffic, and will take decisive action based on predefined rulesets, or in the case of more modern systems, AI and ML.

    Traditional “traffic shaping” technology is also deployed, so if an attack cannot be easily identified as malicious, the bandwidth available to that connection is severely limited to nothing more than a trickle rather than a full flow.

    Years ago, ISP’s used traffic shaping (also called “policers”) as an effective means of stopping applications such as BearShare, eDonkey, Napster, and other P2P based sharing systems from functioning correctly - essentially reducing the “appeal” of distributing and seeding illegal downloads. This was essentially the ISP’s way of saying “stop what you are doing please” without actually pulling the plug.

    These days, DDoS attacks are designed to overwhelm - not assume control of - webservers and other public facing components. It’s rare for small entities to be attacked unless there is some form of political agenda driven by your site or product. A classic example is governmental institutions or lawmakers who effectively are classed as “enforcers” and those who disagree are effectively making a statement in the form of Denial of Service.

    DDoS protection is effectively the responsibility of the hosting provider, but you shouldn’t just assume that they will protect you or your site. Their responsibility stops at their infrastructure, so it’s then up to you too decide how you full the gap in between your host and the website.

    Typically, you’d leverage something like Imunify360 which you can get for Plesk (and something I’d strongly recommend) but it’s not free, and is a paid (not expensive per month) subscription. If you want to use VirtualMin then there are a variety of tools readily available out of the box such as firewalls and fail2ban.

  • KeepSolid VPN Unlimited DEAL

    Configure
    53
    18 Votes
    53 Posts
    4k Views

    @JAC said in KeepSolid VPN Unlimited DEAL:

    although all are going to have their own flaws one way or another,

    Exactly that - none of them are going to suit every individual purpose. You have to read the reviews, decide what functionality you need, and then make a judgement call for yourself (and your own unique needs).

    There is no “wrong or right”, although I would steer clear of those that do not have a no-logs policy for privacy reasons alone.