youtube channel new ID and iframe list user_upload

2020-02-01 07:00发布

问题:

It seems that youtube are now using ID's for their channels instead of names (part of the V3 api)

However it seems that the embedded iframe playlist player cannot handle these channel ID's

example channel https://www.youtube.com/channel/UCpAOGs57EWRvOPXQhnYHpow

then ID is UCpAOGs57EWRvOPXQhnYHpow

Now try to load this

http://www.youtube.com/embed/?listType=user_uploads&list=UCpAOGs57EWRvOPXQhnYHpow

Can anyone shine a light on this issue ? Or is there some hidden username ?

I also placed this question at the gdata-issues website http://code.google.com/p/gdata-issues/issues/detail?id=6463

回答1:

The issue here is that a channel is not a playlist; channels can have multiple playlists, yet the listType parameter is designed to look for an actual playlist info object. The documented way around this is to use the data API and call the channel endpoint, looking at the contentDetails part:

GET https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id=UCuo5NTU3pmtPejmlzjCgwdw&key={YOUR_API_KEY}

The result will give you all of the feeds associated with that channel that you can choose from:

"contentDetails": {
    "relatedPlaylists": {
        "uploads": "UUuo5NTU3pmtPejmlzjCgwdw"
    }
}

If available (sometimes with oAuth), there could also be "watch later" lists, "likes" lists, etc.

This may seem like a lot of overhead. In the short term, though, it can be noted that the different feeds are programmatically named; so, for example, if my user channel begins with UC and then a long string, that UC stands for 'user channel' -- and the uploads feed would begin with 'UU' (user uploads) and then have the rest of the same long string. (you'd also have 'LL' for the likes list, 'WL' for the watch later list, 'HL' for the history list, 'FL' for the favorites list, etc. This is NOT documented, and so there's no guarantee that such a naming convention will perpetuate. But at least for now, you could change your ID string from beginning with UC to beginning with UU, like this:

http://www.youtube.com/embed/?listType=user_uploads&list=UUpAOGs57EWRvOPXQhnYHpow

And it embeds nicely.



回答2:

Just to inform on current state of things -- the change suggested by jlmcdonald doesn't work anymore, but you can still get a proper embed link via videoseries (with the same UC to UU change). I.o.w. link like

http://www.youtube.com/embed/videoseries?list=UUpAOGs57EWRvOPXQhnYHpow

works as of at the moment of writing this.