Youtube API 以及用户、品牌帐户和频道(ID 和 customUrl)之间的关系一直在不断发展,并且有些挑战性。
从我从你的代码中看到的,你的查询看起来应该有效。我刚刚去了YouTube 数据 API 文档 https://developers.google.com/youtube/v3/docs/channels/list并尝试了你的查询。这是一个 JavaScript 示例:
buildApiRequest('GET',
'/youtube/v3/channels',
{'id': 'UCOL10n-as9dXO2qtjjFUQbQ',
'part': 'snippet,contentDetails,statistics'});
这确实产生了一个带有 customUrl 的片段:
/**
* API response
*/
{
"kind": "youtube#channelListResponse",
"etag": "\"DuHzAJ-eQIiCIp7p4ldoVcVAOeY/m5Bxsm15vXTSZAmr8YPFDtFxsSk\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"DuHzAJ-eQIiCIp7p4ldoVcVAOeY/bedKOF-LSDR5WBICufJner6bNMQ\"",
"id": "UCOL10n-as9dXO2qtjjFUQbQ",
"snippet": {
"title": "KinoCheck",
"description": "KinoCheck ist Deutschlands größtes Movie-Entertainment Netzwerk und die Plattform für neue Film Trailer, News und Kritiken in bester Qualität. Wir sind Tag und Nacht für euch im Büro, um sicher zu stellen, dass ihr keine Trailer mehr verpasst. Egal ob Blockbuster wie Deadpool, Star Wars, Fast and Furious oder Indie-Film Trailer, wir haben sie alle! Zusätzlich produzieren wir Original-Inhalte wie Filmkritiken, Mashups, Compilations & Film-Events, damit ihr wisst welcher Film ein wahrer KinoKinoFilm ist.\n\nBesuche unsere offizielle Webseite https://KinoCheck.de und finde spielend leicht den richtigen Film für dich und deine Freunde.\n\nDu sucht nach bestimmten Inhalten, dann checke unsere anderen Kanäle.\nKinoCheck International - Englische Trailer und News\nKinoCheck Home - Home Entertainment Filme auf DVD & Blu-Ray\nKinoCheck Kids - Kinderfreundliche Inhalte und Filme\nuvm.\n\nGründer: Jan Pfriem | KinoCheck™ eine Marke der some.marketing GmbH & Co. KG",
"customUrl": "kinocheck",
"publishedAt": "2012-06-28T10:49:44.000Z",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/a-/AJLlDp0Hm30XcDoxdITElTIgqJbcRrWTQtrGX2q86w=s88-mo-c-c0xffffffff-rj-k-no",
"width": 88,
"height": 88
},
"medium": {
"url": "https://yt3.ggpht.com/a-/AJLlDp0Hm30XcDoxdITElTIgqJbcRrWTQtrGX2q86w=s240-mo-c-c0xffffffff-rj-k-no",
"width": 240,
"height": 240
},
"high": {
"url": "https://yt3.ggpht.com/a-/AJLlDp0Hm30XcDoxdITElTIgqJbcRrWTQtrGX2q86w=s800-mo-c-c0xffffffff-rj-k-no",
"width": 800,
"height": 800
}
},
"defaultLanguage": "de",
"localized": {
"title": "KinoCheck",
"description": "KinoCheck is Germany’s largest movie-entertainment network and your destination for movie trailers, news and reviews in highest quality on a daily basis! Whether blockbusters like Deadpool, Star Wars, Fast and Furious or indie movie trailers — we’ve got them all. In addition, we create original-content like reviews, mashups and compilations, so you’ll always be up to date on the most awesome movies!\n\nDon’t miss our official website https://KinoCheck.de\n\nIf you're searching a specific type of content, don't forget to check our other channels\n\nKinoCheck International - English trailers and news\nKinoCheck Home - German home entertainment DVD & Blu-Ray movie \nKinoCheck Kids - German child-friendly content and movies\netc.\n\nFounder: Jan Pfriem | KinoCheck™ a Brand of some.marketing GmbH & Co. KG"
}
},
"contentDetails": {
"relatedPlaylists": {
"likes": "LLOL10n-as9dXO2qtjjFUQbQ",
"uploads": "UUOL10n-as9dXO2qtjjFUQbQ",
"watchHistory": "HL",
"watchLater": "WL"
}
},
"statistics": {
"viewCount": "1411292351",
"commentCount": "0",
"subscriberCount": "1569200",
"hiddenSubscriberCount": false,
"videoCount": "3058"
}
}
]
}
所以我只能假设这是一个已记录的功能,但在您查询时并未像 @parn 建议的那样实现。
警告:我发现即使 API 将返回 customUrl 值(例如“kinocheck”),您也不能依赖“https://www.youtube.com/c/kinocheck https://www.youtube.com/c/kinocheck”实际上会将您带到一个有效的页面。我们注意到对于某些用户频道和一些“句柄”已更改的企业频道,会出现这种情况。