Search YouTube videos by author

I am using YouTube API 3.0 and want to search videos by author. How would you do it?

I am using python client library.

+2


source to share


1 answer


In the YouTube Data API v3 you need to find UploadsPlaylist from a custom channel and they look for PlaylistItems for that channel.

So, for example, if you want to find GoogleDevelopers downloads, first find their channel_id.

If you don't know the user channel_id, you must call the search resource (with the type set to "channel") to find it:

https://www.googleapis.com/youtube/v3/search?part=id&maxResults=1&q=GoogleDevelopers&type=channel&key= {YOUR_API_KEY}

Return:

{
 "kind": "youtube#searchListResponse",
 "etag": "\"Sja0zsjNVqBAv0D_Jpz6t1GyTzk/fm4P2RLxOAO0xdASI5BagD86H8A\"",
 "pageInfo": {
  "totalResults": 21,
  "resultsPerPage": 1
 },
 "nextPageToken": "CAEQAA",
 "items": [
  {
   "id": {
    "kind": "youtube#channel",
    "channelId": "UC_x5XG1OV2P6uZZ5FSM9Ttw"
   },
   "kind": "youtube#searchResult",
   "etag": "\"Sja0zsjNVqBAv0D_Jpz6t1GyTzk/q4hYefapiMoagc7b_3bYaVZvSJo\""
  }
 ]
}

      

As you can see their channelId = UC_x5XG1OV2P6uZZ5FSM9Ttw



Make a call to the content portion of the channel resource to find their playlist:

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

Which will return this:

{
 "kind": "youtube#channelListResponse",
 "etag": "\"Sja0zsjNVqBAv0D_Jpz6t1GyTzk/ZouMU1qBRkF6DgacOLHE88Xk144\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 1
 },
 "items": [
  {
   "id": "UC_x5XG1OV2P6uZZ5FSM9Ttw",
   "kind": "youtube#channel",
   "etag": "\"Sja0zsjNVqBAv0D_Jpz6t1GyTzk/khrrkvk8Tl0XWRZoN66zqloSJM4\"",
   "contentDetails": {
    "relatedPlaylists": {
     "uploads": "UU_x5XG1OV2P6uZZ5FSM9Ttw"
    }
   }
  }
 ]
}

      

As you can see their playlist ID is UU_x5XG1OV2P6uZZ5FSM9Ttw

Make a call to the PlaylistItems resource to get the videos uploaded by GoogleDevelopers:

https://www.googleapis.com/youtube/v3/playlistItems?part=id%2Csnippet%2CcontentDetails&playlistId=UU_x5XG1OV2P6uZZ5FSM9Ttw&key= {YOUR_API_KEY}

+5


source







All Articles