Freshrss: [Feature Request] Convert YouTube Channel URL to Feed URL

Created on 8 Dec 2018  ·  23Comments  ·  Source: FreshRSS/FreshRSS

Recognize the regular YouTube channel URL and convert the channel URL into the feed URL. Such as:

  1. User goes to subscription management and copies the YouTube channel into the "Add a RSS feed" text field https://www.youtube.com/channel/UCcqVvt66T6dvRpNu5NaTEBg
  2. Once the user clicks on the plus sign, a function recognizes that the input is a YouTube channel URL and converts the URL into the following format:
    https://www.youtube.com/feeds/videos.xml?channel_id=UCcqVvt66T6dvRpNu5NaTEBg
  3. Complete adding the RSS feed

Benefit: Conviently copy paste YouTube channel URLs into FressRSS

Extension

Most helpful comment

I never analyzed the reason, but I am 100% certain that pasting the URL to FRSS didn't work in the past. Even the plugin had troubles detecting the URLs of some channels, while others worked.
So maybe its really an age thing, where certain channels behave differently.
But no matter what: subscribing to Youtube channels without the plugin is less fun than with it 😁

All 23 comments

As someone who subscribes to a frankly embarrassing number of youtube channels, I love this idea. It's probably something better added as an extension, though. I'll see what I can put together.

I wrote this function for ElkArte: https://github.com/elkarte/Elkarte/blob/fb7a61bc72fed3e4bd49d868d07815452436da27/themes/default/scripts/elk_jquery_embed.js#L143-L177

Though in that case my contribution was mainly about getting that timestamp. For getting the video ID you can stick to https://github.com/elkarte/Elkarte/blob/fb7a61bc72fed3e4bd49d868d07815452436da27/themes/default/scripts/elk_jquery_embed.js#L144

But don't forget m.youtube.com and youtu.be.

Could make sense to include this logic in @kevinpapst 's existing YouTube extension
https://github.com/FreshRSS/FreshRSS/issues/1737
https://github.com/kevinpapst/freshrss-youtube

@Alkarex is there an event that could be used? If you sent an event after the user submitted the url and before it will be added to the subscriptions, extensions could convert the url.
I'd like to add the Youtube-URL-conversion to my extension, as I regularly have the same requirement that @bisherbas raised.

@kevinpapst I believe the feed_before_insert hook should do the job (it takes a feed object as first parameter, and returns another feed object).
(See the bottom of https://freshrss.github.io/FreshRSS/en/developers/03_Backend/05_Extensions.html )
If not sufficient, we can add more events.

@kevinpapst I haven't had any chance to dive into things on my end, so if you're intending to insert the conversion into your extension, I'll leave it to you!

P.S. I will also try to look at https://github.com/kevinpapst/freshrss-dilbert/issues/3#issuecomment-442383575 which is slightly related (fetching of external content)

Added a draft PR, see https://github.com/kevinpapst/freshrss-youtube/pull/11

@Frenzie Not sure about the m.youtube.com and youtu.be URLs. I know they exist for Video URLs, but do they exist for Channel URLs as well?

@Alkarex For some reasons, 50% of my tests failed, I received a lot of errors like

A feed could not be found at `https://www.youtube.com/feeds/videos.xml?channel_id=UCAXLYcPBW3AJ52ZAhinOyFQ`. Empty body. [https://www.youtube.com/user/ausfahrttv]

But when I manually test the feed they work. Maybe a problem with redirects during subscription? Or just a problem with my server/installation...

Not sure about the m.youtube.com and youtu.be URLs. I know they exist for Video URLs, but do they exist for Channel URLs as well?

For m.youtube.com I don't really understand what the question is tbh. :-) That's their mobile website, which is basically the same as their regular website but with m instead of www and even worse.

The youtu.be shows I was thinking of something slightly different, which I didn't realize.

My thinking is, toss in a YouTube link, get a feed.

  1. Get the channel ID. Video ID instead of channel ID? Then:
  2. Get the video ID and download the HTML.
  3. Match the source for /channel/. There'll be multiple results, but all with the same ID behind it. Ignore anything but the first match.
  4. Produce the videos.xml address.

That would basically match the behavior on a proper website.

There are also userscripts to that effect: https://greasyfork.org/en/scripts/1760-youtube-rss-feed

(It's a bit complex at first glance because it also adds a button to YouTube itself instead of just the LINK element, but it shows the basic idea.)

Let me rephrase the question: is there a more than 10% chance that a user will copy & paste these URLs into FreshRSS? When I browse the m. the channel URLs only seem to exist from the search and the video detail page. And then when I switch to the mobile view of FreshRSS I don't even see the subscription management.
But yes, supporting g m. vs www. in the regex is simple, so I will add it...

Your use case is a nice-to-have for sure, but I will not add that for now (out of time reasons).
I believe the main use case is copy & pasting of user/channel URLs.

is there a more than 10% chance that a user will copy & paste these URLs into FreshRSS?

I would sure hope not! ;-) The bookmarklet is much more user-friendly than a tedious mobile copy/paste.

@Frenzie What is this bookmarklet you are referring to here? Sounds like something I'd be interested in using. Shamefully, I have been copy pasting YT channel URLs into FreshRSS! :)

On a proper computer it's not particularly tedious, but check under Subscription management → Subscription tools. :-)

We merged yesterday the PR of @kevinpapst (https://github.com/kevinpapst/freshrss-youtube/pull/11) and we fixed the issue mentioned above (feeds not found, Youtube was redirecting SimplePie and changed the URL that we were adding).

There are now two extensions able to convert Youtube channel URL to feed URL, the extension of @kevinpapst being a bit more robust.

Hum, there is no need of any extension to do just that.
Copy-pasting the native YouTube channel URL into FreshRSS just works :-)
Example: https://www.youtube.com/channel/UCnAbNwJjusY7zQ__sQyJlSA

Check https://support.google.com/youtube/answer/6224202

Well, it's true it works for some channels (most of them?), but for some other, it doesn't. Example: https://www.youtube.com/channel/UCnf0fDz1vTYW-sl36wbVMbg

I never found a channel for which it was working before (I stopped to try to be exact ^^), I didn't know it was working for some channels!

Strange...

Copy-pasting the native YouTube channel URL into FreshRSS just works :-)
Example: https://www.youtube.com/channel/UCnAbNwJjusY7zQ__sQyJlSA

Wait… it does. But how?!

Check https://support.google.com/youtube/answer/6224202

Because that's not how, or at least not exactly. The fact that it's absurdly difficult to obtain that link (due to no <link rel="alternate" etc.) is the very issue in the first place.

But I notice that if I run that link in curl as opposed to my browser, it does in fact include this… for the example you somehow managed to cherry pick. :-P

    <link rel="alternate" type="application/rss+xml" title="RSS" href="https://www.youtube.com/feeds/videos.xml?channel_id=UCnAbNwJjusY7zQ__sQyJlSA">

So somehow I got the impression this never ever works, and you got the impression this always works. :rofl:

I think the age of the channel may be a factor. Channels dating from ~2014 onward don't seem to secretly offer the RSS link under the right conditions, while those from 2013 and older do.

Perhaps I "incorrectly" extrapolated from not seeing an RSS icon in my addressbar. This indicates there's no link rel=alternate in the source, without any need to double check although of course I did. Or from purely accidentally checking a couple of post-2014 channels because I'd swear I actually pasted at least one channel link into FreshRSS before. (Another sufficiently plausible scenario: YouTube changed something again.)

Anyway, I don't know if the ~2014 split is the correct analysis, but that's the way it looks to me right now after checking about a dozen of them.

I never analyzed the reason, but I am 100% certain that pasting the URL to FRSS didn't work in the past. Even the plugin had troubles detecting the URLs of some channels, while others worked.
So maybe its really an age thing, where certain channels behave differently.
But no matter what: subscribing to Youtube channels without the plugin is less fun than with it 😁

Indeed, the extensions are doing more than just finding the feed. Remember to have the correct HTTP Accept header when testing URLs

Was this page helpful?
0 / 5 - 0 ratings