Reputation: 392
The youtube channel that I am pulling videos from has a section called "Popular Uploads", this seems to be a section that is automatically created by youtube. I am wondering if anyone has experience in pulling videos from this section? I am using 3.0 (which may be the only version that supports sections).
Here is an example of the section object with the ids removed
Object {kind: "youtube#channelSection", etag: ""etag"", id: "channel.section", snippet: Object}
etag: ""etag""
id: "channel.section"
kind: "youtube#channelSection"
snippet: Object
channelId: "channel"
position: 2
style: "verticalList"
type: "popularUploads"
There are examples of pulling in Most Popular videos in the documentation, but that only seems to be site wide, not for a specific channel.
Thank you.
Upvotes: 1
Views: 130
Reputation: 13667
When it comes to channel sections, most of them are defined by the owner of the channel, and as such a call to the channelSections endpoint can retrieve the playlist IDs in each section's contentDetails. However, as you've surmised, the "popular uploads" is a section that is returned by the API but doesn't have its own playlist ID associated with it. That's because it is dynamically generated on each request (or more likely cached and refreshed every so often), using information that the API itself gets about view counts for the channel's videos as a whole.
Luckily, you can recreate (with pretty complete accuracy as far as I can tell) the exact call that the popularUploads section makes behind the scenes, and get those videos yourself for a channel. If you already know the channelId (which you seem to imply you do), then hit the end point
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId={CHANNEL_ID}&order=viewCount&key={YOUR_API_KEY}
(or in your client of choice, use the search->list method, passing the channelId parameter and the order parameter set to viewCount).
In other words, that channel section just does a channel-based search and orders them by the number of views. I tested with several channels, and the search results through the API are matching what the channel's UI is showing.
Upvotes: 2