solvingPuzzles
solvingPuzzles

Reputation: 8889

Given a YouTube video, programmatically get its channel?

I've found at least five Stack Overflow questions of the form "here is a YouTube channel, how do I programmatically obtain the videos on this channel?"

I want to do the opposite: given a video, what channel did it come from?

So far, I've looked for solutions on this in the official YouTube API. I've also looked at libraries like pafy. No luck so far.

Upvotes: 4

Views: 469

Answers (1)

Kenny
Kenny

Reputation: 4572

https://developers.google.com/youtube/v3/docs/videos/list

It looks like you can make a video request, then set:

part=snippet

This will return the channelId, among other things. I did a request like so:

GET https://www.googleapis.com/youtube/v3/videos?part=snippet&id=f8WsO__XcI0&key={YOUR_API_KEY}

and I get the response:

 {

 ...

 "items": [
  {

   "kind": "youtube#video",
   "etag": "\"IHLB7Mi__JPvvG2zLQWAg8l36UU/Xn3r39kJJF0iqtZbqFIeFUTgC0Q\"",
   "id": "f8WsO__XcI0",
   "snippet": {
    "publishedAt": "2015-04-13T21:20:53.000Z",
    "channelId": "UC6nSFpj9HTCZ5t-N3Rm3-HA",

 ...

 }

Upvotes: 1

Related Questions