Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

YouTube API: Get upload playlistID for YouTube Channel

$
0
0

I'm trying to figure out the best way to get a channel's upload playlistID given the channel's channelID. E.g. for the channel with channelID

UC9CuvdOVfMPvKCiwdGKL3cQ

The corresponding upload playlistID is

UU9CuvdOVfMPvKCiwdGKL3cQ

Notice the second character has changed from a "C" to a "U"

I can do this transformation via string manipulation, but I'm curious if there's a better, less hacky way to find the upload playlist ID through the official youtube api.

Here's some Kotlin code that shows my issue:

I can find the ChannelID for the "Game Grumps" channel through the following youtube api v3 search:

            val req = youtube.search().list("snippet");            req.key = {API_KEY}            req.q = "Game Grumps"            req.type = "channel"            val response = req.execute();

The resulting Channel id (response.items[0].snippet.channelId) is UC9CuvdOVfMPvKCiwdGKL3cQ

But when I run the following to try to get the videos uploaded by the channel, I have to use the transformed ChannelID (starting with UU instead of UC)

            val req = youtube.PlaylistItems().list("snippet")            req.playlistId = "UU9CuvdOVfMPvKCiwdGKL3cQ"            req.key = {API_KEY}            val response = req .execute()

If I use the untransformed "UC" channelID, I get the following error: The playlist identified with the requests playlistId parameter cannot be found.

Instead of just replacing the second character with a "U", what's the more robust way (e.g. using the youtube API) of translating a ChannelID to a PlaylistID (for the uploads from that channel)?


Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>