Reputation: 103
I am trying to get all videos of a channel. I am getting the video id and thumbnails etc...but i am not able get likes, dis likes and comments count of a video.
For example: here i am using BBC News channel id in the below url.
https://www.googleapis.com/youtube/v3/search?key={MY API KEY}&channelId=UC16niRr50-MSBwiO3YDb3RA&part=snippet,id&order=date&maxResults=20
With this url i am getting viedo information but not likes, dis likes and comments count of a individual video.
Please help me. TIA
Upvotes: 4
Views: 4619
Reputation: 1733
It is not possible to get the search results along with the all the video information ( likecount, etc) on a single api call. However you can implement it programatically by
1) first get the search results
2) get video info of each result firing another api call
You can get all the details of the video by specifying the part as contentDetails,statistics,snippet
payload = {'id': search_result["id"]["videoId"], 'part': 'contentDetails,statistics,snippet', 'key': DEVELOPER_KEY}
l = requests.Session().get('https://www.googleapis.com/youtube/v3/videos', params=payload)
print l.text
Response will be as following:
{
"kind": "youtube#videoListResponse",
"etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/EMbbi9ruIqgq1ERymR5oC-ODvkE\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/nk4zkCbyR6ftbwbccNAGvGN4ay0\"",
"id": "gm0iQQyKHlQ",
"snippet": {
"publishedAt": "2017-05-05T04:33:36.000Z",
"channelId": "UCsvNpjj4RxIRXnY9lOeTq-g",
"title": "Kasaba Malayalam Full Movie | Latest Mammootty Movie | New Malayalam Film | Mammootty Movies",
"description": "latest mammootty malayalam movie full HD\nkasaba malayalam movie\nmalayalam new films",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/gm0iQQyKHlQ/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/gm0iQQyKHlQ/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/gm0iQQyKHlQ/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/gm0iQQyKHlQ/sddefault.jpg",
"width": 640,
"height": 480
},
"maxres": {
"url": "https://i.ytimg.com/vi/gm0iQQyKHlQ/maxresdefault.jpg",
"width": 1280,
"height": 720
}
},
"channelTitle": "malayalam new films",
"tags": [
"malayalam new films",
"new movies",
"new movies 2017 full movies",
"latest movies",
"malayalam movie new",
"malayalam film",
"malayalam film new",
"malayalam full movie",
"new",
"film",
"movie",
"cinema",
"songs",
"kasaba malayalam movie",
"kasaba",
"kasaba full movie",
"kasaba hot",
"kasaba songs",
"kasaba scenes",
"kasaba movie",
"kasaba full movie online",
"mammootty",
"mammootty malayalam full movie",
"mammootty new movie trailer",
"mammootty songs",
"mammootty great father",
"puthan panam",
"Varalaxmi Sarathkumar",
"Neha Saxena"
],
"categoryId": "1",
"liveBroadcastContent": "none",
"localized": {
"title": "Kasaba Malayalam Full Movie | Latest Mammootty Movie | New Malayalam Film | Mammootty Movies",
"description": "latest mammootty malayalam movie full HD\nkasaba malayalam movie\nmalayalam new films"
}
},
"contentDetails": {
"duration": "PT2H15M59S",
"dimension": "2d",
"definition": "hd",
"caption": "false",
"licensedContent": true,
"regionRestriction": {
"blocked": [
"IN"
]
},
"projection": "rectangular"
},
"statistics": {
"viewCount": "437181",
"likeCount": "1135",
"dislikeCount": "391",
"favoriteCount": "0",
"commentCount": "40"
}
}
]
}
Upvotes: 0
Reputation: 4185
The search results just contain basic information. You have to then take the video ids from the search results and make a separate API request to get the details you want for the videos.
https://www.googleapis.com/youtube/v3/videos?key={MY API KEY}&part=statistics&id={IDs}
IDs are a comma separated list of the video id's you retrieved from the search.
Upvotes: 6