我正在使用YouTube API V3获取频道的视频,但它返回错误的视频数量。该频道总共有11个视频,但是当我调用API时,我只得到6个(或7个,我不知道情况),如果我指定maxResults参数为11或更高。
如何解决这个问题?谢谢。我在我的youtube帐户中没有找到任何设置。
为了演示它,通道ID为:UCOjT220XvzZrX6LuZ6GnrGQ当我调用
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCOjT220XvzZrX6LuZ6GnrGQ&maxResults=13&order=date&key=[API_KEY]
我可以得到你提到的11个视频:
{
"kind": "youtube#searchListResponse",
"etag": ""sGDdEsjSJ_SnACpEvVQ6MtTzkrI/HAvUl5A7ZOXUisEPHf47emX1hL0"",
"pageInfo": {
"totalResults": 12,
"resultsPerPage": 13
},
"items": [
{
"kind": "youtube#searchResult",
"etag": ""sGDdEsjSJ_SnACpEvVQ6MtTzkrI/PgKUDIanQqJM06eGCdOcY1k8U2E"",
"id": {
"kind": "youtube#video",
"videoId": "wgIGFp6LTpg"
},
"snippet": {
"publishedAt": "2015-02-27T09:00:41.000Z",
"channelId": "UCOjT220XvzZrX6LuZ6GnrGQ",
"title": "Trapianto di Cornea DALK",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/wgIGFp6LTpg/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/wgIGFp6LTpg/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/wgIGFp6LTpg/hqdefault.jpg"
}
},
"channelTitle": "",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": ""sGDdEsjSJ_SnACpEvVQ6MtTzkrI/iI_e3liC80z1dubSCRt-GMMglqU"",
"id": {
"kind": "youtube#video",
"videoId": "M48hn7bBof8"
},
"snippet": {
"publishedAt": "2015-02-27T08:57:31.000Z",
"channelId": "UCOjT220XvzZrX6LuZ6GnrGQ",
"title": "Cheratoprotesi di Boston",
"description": "La cornea artificiale è l'ultima frontiera per la cura delle malattie della cornea. Ne esistono di diversi tipi: la piu utilizzata è la Cornea artificiale (cheratoprotesi) di ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/M48hn7bBof8/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/M48hn7bBof8/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/M48hn7bBof8/hqdefault.jpg"
}
},
"channelTitle": "",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": ""sGDdEsjSJ_SnACpEvVQ6MtTzkrI/0UZloLuYjiuCboAS78hx0Crez3E"",
"id": {
"kind": "youtube#video",
"videoId": "Y2I2ZLpKDc8"
},
"snippet": {
"publishedAt": "2015-02-26T14:50:09.000Z",
"channelId": "UCOjT220XvzZrX6LuZ6GnrGQ",
"title": "Intralase",
"description": "Tecnologia laser a femtosecondi di Abbott Laboratories sulla quale si basa l'intervento LASIK.",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/Y2I2ZLpKDc8/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/Y2I2ZLpKDc8/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/Y2I2ZLpKDc8/hqdefault.jpg"
}
},
"channelTitle": "",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": ""sGDdEsjSJ_SnACpEvVQ6MtTzkrI/d8MMhw3T03DfFfUHMUUkSWuOPyI"",
"id": {
"kind": "youtube#video",
"videoId": "SbhcbwTLX7c"
},
"snippet": {
"publishedAt": "2015-02-26T14:26:30.000Z",
"channelId": "UCOjT220XvzZrX6LuZ6GnrGQ",
"title": "Trapianto di Cornea Endotelio DSAEK",
"description": "Trapianto di endotelio della cornea (DSAEK) con iniettore NCI. Nuova tecnica di trapianto di cornea per pazienti con distrofia di Fuchs o edema della cornea ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/SbhcbwTLX7c/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/SbhcbwTLX7c/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/SbhcbwTLX7c/hqdefault.jpg"
}
},
"channelTitle": "",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": ""sGDdEsjSJ_SnACpEvVQ6MtTzkrI/Mb5mqYX17_L_9Y5t9FwSUcUhXI0"",
"id": {
"kind": "youtube#video",
"videoId": "hKgget6QLMM"
},
"snippet": {
"publishedAt": "2015-02-25T14:18:26.000Z",
"channelId": "UCOjT220XvzZrX6LuZ6GnrGQ",
"title": "Cheratoprotesi di Boston: Trapianto di Cornea",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/hKgget6QLMM/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/hKgget6QLMM/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/hKgget6QLMM/hqdefault.jpg"
}
},
"channelTitle": "",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": ""sGDdEsjSJ_SnACpEvVQ6MtTzkrI/qWC6lNxyC2DanUqXZjh9hnCE6a0"",
"id": {
"kind": "youtube#video",
"videoId": "Zxe6N9gLYOk"
},
"snippet": {
"publishedAt": "2015-02-25T14:13:30.000Z",
"channelId": "UCOjT220XvzZrX6LuZ6GnrGQ",
"title": "Chirurgia Cataratta con lente Hi Tech",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/Zxe6N9gLYOk/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/Zxe6N9gLYOk/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/Zxe6N9gLYOk/hqdefault.jpg"
}
},
"channelTitle": "",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": ""sGDdEsjSJ_SnACpEvVQ6MtTzkrI/4fEXZSXNyt6Er2llnk-Tq1-H3Xo"",
"id": {
"kind": "youtube#video",
"videoId": "d-txNN-7LvE"
},
"snippet": {
"publishedAt": "2015-02-25T14:08:48.000Z",
"channelId": "UCOjT220XvzZrX6LuZ6GnrGQ",
"title": "Chirurgia Cheratocono con INTACTS - Chirurgia Live",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/d-txNN-7LvE/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/d-txNN-7LvE/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/d-txNN-7LvE/hqdefault.jpg"
}
},
"channelTitle": "",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": ""sGDdEsjSJ_SnACpEvVQ6MtTzkrI/EeTGCvw9RrGuPB3KDSzZR0iGMEA"",
"id": {
"kind": "youtube#video",
"videoId": "Imtlb7qmags"
},
"snippet": {
"publishedAt": "2015-02-25T14:05:24.000Z",
"channelId": "UCOjT220XvzZrX6LuZ6GnrGQ",
"title": "Chirurgia Cheratocono con INTACTS - Animazione",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/Imtlb7qmags/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/Imtlb7qmags/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/Imtlb7qmags/hqdefault.jpg"
}
},
"channelTitle": "",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": ""sGDdEsjSJ_SnACpEvVQ6MtTzkrI/ssmNJT0LbRQRRlTGjJ-wbCNh5SM"",
"id": {
"kind": "youtube#video",
"videoId": "ryWlPp29kiI"
},
"snippet": {
"publishedAt": "2015-02-25T13:57:46.000Z",
"channelId": "UCOjT220XvzZrX6LuZ6GnrGQ",
"title": "Correzione Miopia, Ipermetropia e Cataratta con la lente Hi Tech",
"description": "Correggere miopia, astigmatismo, presbiopia ed ipermetropia è possibile in un unico intervento grazie alla lente Hi-tech. Si tratta di un cristallino artificiale che ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/ryWlPp29kiI/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/ryWlPp29kiI/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/ryWlPp29kiI/hqdefault.jpg"
}
},
"channelTitle": "",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": ""sGDdEsjSJ_SnACpEvVQ6MtTzkrI/YHFCRZaoPNuTzlLHmOAWzyydvZw"",
"id": {
"kind": "youtube#video",
"videoId": "RJmm40oaVwk"
},
"snippet": {
"publishedAt": "2015-02-25T13:52:07.000Z",
"channelId": "UCOjT220XvzZrX6LuZ6GnrGQ",
"title": "Chirurgia della Cataratta: novità",
"description": "La più grande innovazione in chirurgia della cataratta è la lente Hi-Tech che permette di curare in un unico intervento miopia, astigmatismo, presbiopia e ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/RJmm40oaVwk/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/RJmm40oaVwk/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/RJmm40oaVwk/hqdefault.jpg"
}
},
"channelTitle": "",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": ""sGDdEsjSJ_SnACpEvVQ6MtTzkrI/rs7lh7958amlLisrvdxndE1neAc"",
"id": {
"kind": "youtube#video",
"videoId": "4sfAlyiSA8s"
},
"snippet": {
"publishedAt": "2015-02-25T08:35:34.000Z",
"channelId": "UCOjT220XvzZrX6LuZ6GnrGQ",
"title": "Lente Intraoculare Hi Tech",
"description": "I difetti della vista: miopia, astigmatismo, presbiopia e ipermetropia si possono finalmente correggere con un unico intervento: la chirurgia con la lente Hi-Tech o ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/4sfAlyiSA8s/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/4sfAlyiSA8s/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/4sfAlyiSA8s/hqdefault.jpg"
}
},
"channelTitle": "",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": ""sGDdEsjSJ_SnACpEvVQ6MtTzkrI/NAW_LlewyAxUlC7o6lL1oQxW2VY"",
"id": {
"kind": "youtube#channel",
"channelId": "UCOjT220XvzZrX6LuZ6GnrGQ"
},
"snippet": {
"publishedAt": "2015-02-24T18:10:32.000Z",
"channelId": "UCOjT220XvzZrX6LuZ6GnrGQ",
"title": "Micro Chirurgia Oculare - dott. Federico Badalà",
"description": "Il Dott. Federico Badalà dopo aver a lungo lavorato in USA è stato il primo chirurgo oculista italiano ad eseguire interventi innovativi nel campo della chirurgia ...",
"thumbnails": {
"default": {
"url": "https://lh5.googleusercontent.com/-lvWU6W_lntU/AAAAAAAAAAI/AAAAAAAAAAA/yKCZSRHZcNI/photo.jpg"
},
"medium": {
"url": "https://lh5.googleusercontent.com/-lvWU6W_lntU/AAAAAAAAAAI/AAAAAAAAAAA/yKCZSRHZcNI/photo.jpg"
},
"high": {
"url": "https://lh5.googleusercontent.com/-lvWU6W_lntU/AAAAAAAAAAI/AAAAAAAAAAA/yKCZSRHZcNI/photo.jpg"
}
},
"channelTitle": "",
"liveBroadcastContent": "none"
}
}
]
}
由于一些奇怪的原因,当我复制你在评论中发布的URL时,它不起作用,但是当我复制上面发布的channelId并粘贴在你的URL中时,它起作用了(即使它是相同的ID,多么奇怪…)。您可以尝试这样做的另一种方法是使用playlistItems.list
并提供您的上传播放列表ID(您可以通过调用channels获得该ID)。列表并指定part=contentDetails
),它以倒叙的时间顺序提供您上传的视频。
https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=UUOjT220XvzZrX6LuZ6GnrGQ&maxResults=13&key=[API_KEY]