pipes-digital / pipes

Repository for Pipes
https://pipes.digital
GNU Affero General Public License v3.0
261 stars 21 forks source link

Automatically parse Youtube URLs to get channel or user's feed #20

Open anewuser opened 7 years ago

anewuser commented 7 years ago

A useful idea from Inoreader is to convert Youtube URLs in feed blocks to their appropriate feed URLs automatically on your server side, since Youtube doesn't embed the addresses in its pages, and people would need to look it up manually every time they create a new pipe.

Examples of URLs formats that may be entered in a feed block, and their corresponding feeds:

Channel:

https://www.youtube.com/channel/EXAMPLE/videos (featured|videos|about|etc.) Actual feed: https://www.youtube.com/feeds/videos.xml?channel_id=EXAMPLE

User page:

https://www.youtube.com/user/EXAMPLE/videos (featured|videos|about|etc.) Actual feed: https://www.youtube.com/feeds/videos.xml?user=EXAMPLE

Playlist:

https://www.youtube.com/playlist?list=EXAMPLE / https://www.youtube.com/watch?v=FOO&list=EXAMPLE Actual feed: https://www.youtube.com/feeds/videos.xml?playlist_id=EXAMPLE

onli commented 7 years ago

That's even a complete list of scenarios, isn't it? Playlists, channels, user page feeds.

anewuser commented 7 years ago

Well, hopefully your users will be "computer literate" enough to enter URLs that include the channel or user ID (which can be manipulated with regexes to get the feeds, like in my examples), so those are all scenarios. :)

If someone is inclined to enter a direct video URL, you'd have to make use of Youtube APIs to get the feed, but I doubt that they'd be interested in your service in first place.

onli commented 7 years ago

Okay then. Thanks, this is a great idea. I got it implemented in the current dev version, it will go live with the next update.

onli commented 7 years ago

This feature is also online now. Could you give me feedback whether this works as expected for you?

anewuser commented 7 years ago

It worked with the URLs I inserted to test it. I'll report it if I run through any problems.

Out of the other changes, I think that "My Pipes" should have a consistent position in the menu (it's visible on the frontpage but hidden once you open a pipe), and the settings button looks like a "turn off" icon, so my first guess was that it was a "logout" button.

onli commented 7 years ago

Super, thanks.

the settings button looks like a "turn off" icon, so my first guess was that it was a "logout" button

Oh, which button do you mean exactly?

I think that "My Pipes" should have a consistent position in the menu (it's visible on the frontpage but hidden once you open a pipe)

Yeah, I'm not sure about that. On the one hand you are right, that should be consistent. On the other it does not make sense to have a profile avatar and menu on the landing page. I'm conflicted there, thanks for the feedback though!

anewuser commented 7 years ago

aa6565858d3a61987e46447847e700c2

onli commented 7 years ago

If you see that image at the top right, then that should be there because it is your gravatar image. I remember that one being used by Wordpress, maybe they set it as default in the past? Not sure though.

But I do indeed think that menu is a bit too hidden, but I'm not sure how to fix that.

anewuser commented 7 years ago

It must still be the default then (at least for the API you use), because the email address I'm using with your service is new and I haven't set a Gravatar for it.

anewuser commented 5 years ago

@onli can you please take a look at this? The second feed (a Youtube playlist) is causing errors: -edited-

onli commented 5 years ago

@anewuser Sure. It looks like there was an additional situation where the system could not find the feed link. I added a workaround and it seems to work now. Could you test again?

anewuser commented 5 years ago

Thank you!

anewuser commented 3 years ago

@onli

URLs that start with https://www.youtube.com/c/NoCopyrightSounds should redirect to https://www.youtube.com/feeds/videos.xml?channel_id=UC_aEa8K-EOJ3D6gOs7HcyNg

onli commented 3 years ago

I tried to get around parsing the youtube page by instead redirecting to https://www.youtube.com/feeds/videos.xml?user=NoCopyrightSounds - that works equally well here, right?

anewuser commented 3 years ago

That depends on whether it started off as a regular user or a brand account. The previous example is actually a user account, because https://www.youtube.com/user/NoCopyrightSounds/ works too.

Here's an example of a brand account: https://www.youtube.com/c/dwpolski/videos / https://www.youtube.com/dwpolski/videos (the /c/ part seems to be optional). These links don't work on Pipes currently.

For these cases (Youtube links that don't include /user/, /channel/, or /playlist?), I think that you'd have to get the canonical channel ID from the source code (<link rel="canonical" href="https://www.youtube.com/channel/UCgLYY5Ghbnw-e1ItZg8Y82g">) and then add it to https://www.youtube.com/feeds/videos.xml?channel_id=.

onli commented 3 years ago

Alright, great to know!

Let's start with the canoncal url parsing when the url contains /c/. I added that in https://github.com/pipes-digital/pipes/commit/914841c1a23b5a0966e3b5f4455f368f1e693dea

https://www.youtube.com/dwpolski/videos (the /c/ part seems to be optional). These links don't work on Pipes currently.

For that one in general we do not detect youtube's /videos page yet. But that could be added I think. And right, we could do that in general for all channel pages, with the canoncial url detection.