搜索 YouTube 视频时长、频道和观看次数
Search for YouTube videos duration, channel, and view count
我想使用 YouTube 搜索 API (v3) 来根据关键字搜索视频。它运行良好,这是我收到的示例:
{
"kind": "youtube#searchResult",
"etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/hJdddtiTPMTxfi76U5-OfoXwfPE\"",
"id": {
"kind": "youtube#video",
"videoId": "TE9TpraPlrE"
},
"snippet": {
"publishedAt": "2010-06-29T17:00:38.000Z",
"channelId": "UCikzJG7RbnNZhKLqqaXRM6A",
"title": "What is SharePoint? | lynda.com overview",
"description": "This web development overview explores what SharePoint is and how it works. Watch more at ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/TE9TpraPlrE/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/TE9TpraPlrE/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/TE9TpraPlrE/hqdefault.jpg"
}
},
"channelTitle": "lyndapodcast",
"liveBroadcastContent": "none"
}
}
但是,我遗漏了一些信息,例如时长、频道的真实名称和观看次数。我想还有另一个 API 入口点可以获取有关一个或多个视频的信息,但是是否有可能在一次调用中获取所有这些信息?这意味着搜索 API 也会 return 他们还是我被迫总结搜索 return 编辑的所有视频并再次调用以获取所有这些视频的信息?
持续时间、频道和观看次数未由 search. You will need to pass the videoId
's to video return 编辑以获得您需要的信息。例如,使用 videoId
Pxb5lSPLy9c
并设置 part
以显示 statistics
和 contentDetails
将导致持续时间和观看次数的 return。
要求:
GET https://www.googleapis.com/youtube/v3/videos?part=statistics%2C+contentDetails&id=Pxb5lSPLy9c&key={YOUR_API_KEY}
响应:
{
"kind": "youtube#videoListResponse",
"etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/2DniKZoxyNGn7I9fMnpuXArVy7I\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/866ffq8I1qvVuqduMHhbik3U_Ow\"",
"id": "Pxb5lSPLy9c",
"contentDetails": {
"duration": "PT9M18S",
"dimension": "2d",
"definition": "hd",
"caption": "true",
"licensedContent": true
},
"statistics": {
"viewCount": "3112372",
"likeCount": "125358",
"dislikeCount": "973",
"favoriteCount": "0",
"commentCount": "10242"
}
}
]
}
我想使用 YouTube 搜索 API (v3) 来根据关键字搜索视频。它运行良好,这是我收到的示例:
{
"kind": "youtube#searchResult",
"etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/hJdddtiTPMTxfi76U5-OfoXwfPE\"",
"id": {
"kind": "youtube#video",
"videoId": "TE9TpraPlrE"
},
"snippet": {
"publishedAt": "2010-06-29T17:00:38.000Z",
"channelId": "UCikzJG7RbnNZhKLqqaXRM6A",
"title": "What is SharePoint? | lynda.com overview",
"description": "This web development overview explores what SharePoint is and how it works. Watch more at ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/TE9TpraPlrE/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/TE9TpraPlrE/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/TE9TpraPlrE/hqdefault.jpg"
}
},
"channelTitle": "lyndapodcast",
"liveBroadcastContent": "none"
}
}
但是,我遗漏了一些信息,例如时长、频道的真实名称和观看次数。我想还有另一个 API 入口点可以获取有关一个或多个视频的信息,但是是否有可能在一次调用中获取所有这些信息?这意味着搜索 API 也会 return 他们还是我被迫总结搜索 return 编辑的所有视频并再次调用以获取所有这些视频的信息?
持续时间、频道和观看次数未由 search. You will need to pass the videoId
's to video return 编辑以获得您需要的信息。例如,使用 videoId
Pxb5lSPLy9c
并设置 part
以显示 statistics
和 contentDetails
将导致持续时间和观看次数的 return。
要求:
GET https://www.googleapis.com/youtube/v3/videos?part=statistics%2C+contentDetails&id=Pxb5lSPLy9c&key={YOUR_API_KEY}
响应:
{
"kind": "youtube#videoListResponse",
"etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/2DniKZoxyNGn7I9fMnpuXArVy7I\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/866ffq8I1qvVuqduMHhbik3U_Ow\"",
"id": "Pxb5lSPLy9c",
"contentDetails": {
"duration": "PT9M18S",
"dimension": "2d",
"definition": "hd",
"caption": "true",
"licensedContent": true
},
"statistics": {
"viewCount": "3112372",
"likeCount": "125358",
"dislikeCount": "973",
"favoriteCount": "0",
"commentCount": "10242"
}
}
]
}