Youtubeexplode: Get Channel Subscriptions and Playlists

Created on 4 Aug 2017  路  15Comments  路  Source: Tyrrrz/YoutubeExplode

From channel id get it's subscriptions and playlists if publicly available.

GetChannelSubscribtionsAsync(string channelId)
returns IEnumerable<string> ChannelIds //at minimum maybe there would be more info available

GetChannelPlaylistsAsync(string channelId)
returns IEnumerable<string> PlaylistIds //at minimum maybe there would be more info available

Or maybe it is possible to get everything through GetChannelInfoAsync(string channelId)?

I haven't looked on how to do this. Worst case scenario would be to parse/scrape channel page.

https://www.youtube.com/channel/{channelId}/channels
https://www.youtube.com/channel/{channelId}/playlists

enhancement wontfix

Most helpful comment

I was wondering if this could be done without the API and it does appear to be possible and even relatively simple as well.

Youtube embeds a JSON object into the source of the playlist page which is then processed by polymer (the JS frontend) in order to show content.

Here is a gist from the information from the following page: https://www.youtube.com/user/LinusTechTips/playlists
https://gist.github.com/Zyano/857e5a4ad8df73e41b63aad6a71277b5

The section in the gist is layered in the HTML like this.

<script > window["ytInitialData"] = JSON SNIPPET/GIST GOES HERE window["ytInitialPlayerResponse"] = (null); if (window.ytcsi) {window.ytcsi.tick("pdr", null, '');} </script>

It should be possible to parse this information to get the desired result.

All 15 comments

Doesn't look like there's a way to get around parsing HTML :/

I'm thinking maybe we should define a stricter scope of what YoutubeExplode should or shouldn't do. I'm not sure if I want it to turn into an alternative to Google API without the API key.

Well, I can't really decide that, you do what you think is best, I could always write Extensions lib to do this parsing if I really need :)

In that case, maybe you want to make it into a pull request? 馃槢

We'll see, if I be in need of implementation for this, I will :)

I was wondering if this could be done without the API and it does appear to be possible and even relatively simple as well.

Youtube embeds a JSON object into the source of the playlist page which is then processed by polymer (the JS frontend) in order to show content.

Here is a gist from the information from the following page: https://www.youtube.com/user/LinusTechTips/playlists
https://gist.github.com/Zyano/857e5a4ad8df73e41b63aad6a71277b5

The section in the gist is layered in the HTML like this.

<script > window["ytInitialData"] = JSON SNIPPET/GIST GOES HERE window["ytInitialPlayerResponse"] = (null); if (window.ytcsi) {window.ytcsi.tick("pdr", null, '');} </script>

It should be possible to parse this information to get the desired result.

Any news or developments on this? This would be a neat thing to have.

As for your query a year ago @Tyrrrz, I might as well comment on that.
I personally view YoutubeExplode as one of the better alternatives to the YouTube API, and I feel it'd be nice for it to expand a bit more. If it can be scraped in a reliable way, we should be able to access it.

Just my two cents worth :)

I don't have any stake in this, so I'm not planning to implement this myself. 馃槢
If somebody has a working solution, please raise a PR.

Gist for pulling all of the playlists from ytInitialPlayerResponse bit slow and horrible but it does the job. Doesn't get all playlists as I have not implemented pagination

https://gist.github.com/Themodem/a73bf110a4213f273b44434eb721cae4

@Tyrrrz Is this feature something you wish YoutubeExplode to support? I'm currently making this feature for myself since the changes to the amount of API requests youtube allow and was wondering if this has any interest.

There are a few gotchas around my current implementation which relies on AngleSharp and AngleSharp.Io which in turn conflicts with the .net45 and netstandard1.1 support.

I'm aware the issue has been "dead" for a while

Hi @Zyano
First of all, thank you for your interest. 馃檪
Personally, I have no stake in this feature and it doesn't seem that a lot of people need it (although I may be wrong).
The only reason I'm "careful" about adding new functionality is that I later have to support it when YouTube inevitably changes something.
That said, if the implementation is reasonably simple, it may be nice to have it in.

I will go ahead and clean it up and submit a PR then we can have an easier discussion about the changes to see if it's the right fit.

For those that didn't read the conversation in the PR. It was decided that the feature requires too many changes in order to be supported.

@Tyrrrz
I guess the question remaining is "should this enhancement be closed or updated in some way"

Yeah it turned out a bit too big than I had hoped. I thought it would be around the size of @Themodem's solution.
I'm leaning towards descoping this personally but open for opinion.

Descoping to avoid maintenance creep.

Was this page helpful?
0 / 5 - 0 ratings