如何使用 YouTube API 获取频道名称?



我想获取视频的频道名称,但它给出了播放列表名称。我目前正在使用此网址var urlString = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&pageToken=(pageToken)&playlistId=PLFgquLnL59alCl_2TQvOiD5Vgm1hCaGSI&key=(apiKey)"

它现在给了我这样的东西。

["items": <__NSArrayI 0x1c0472540>(
{
etag = ""DuHzAJ-eQIiCIp7p4ldoVcVAOeY/Vq7FiiHfUpgAr9yq9YxmBXwSLrE"";
id = UExGZ3F1TG5MNTlhbENsXzJUUXZPaUQ1VmdtMWhDYUdTSS4xNDU2QkYwRjk0NkZBOEVD;
kind = "youtube#playlistItem";
snippet =     {
channelId = "UC-9-kyTW8ZkZNDHQJ6FgpwQ";
channelTitle = Music;
description = "U201cThis is AmericaU201d by Childish Gambino http://smarturl.it/TcIgAnDirector: Hiro MurainProducer: Jason Cole of Doomsday with Ibra Ake and Fam Rothstein of Wolf + Rothsteinntour tickets and merchandise available at childishgambino.com";
playlistId = "PLFgquLnL59alCl_2TQvOiD5Vgm1hCaGSI";
position = 0;
publishedAt = "2018-05-18T11:29:31.000Z";
resourceId =         {
kind = "youtube#video";
videoId = VYOjWnS4cMY;
};
thumbnails =         {
default =             {
height = 90;
url = "https://i.ytimg.com/vi/VYOjWnS4cMY/default.jpg";
width = 120;
};
high =             {
height = 360;
url = "https://i.ytimg.com/vi/VYOjWnS4cMY/hqdefault.jpg";
width = 480;
};
maxres =             {
height = 720;
url = "https://i.ytimg.com/vi/VYOjWnS4cMY/maxresdefault.jpg";
width = 1280;
};
medium =             {
height = 180;
url = "https://i.ytimg.com/vi/VYOjWnS4cMY/mqdefault.jpg";
width = 320;
};
standard =             {
height = 480;
url = "https://i.ytimg.com/vi/VYOjWnS4cMY/sddefault.jpg";
width = 640;
};
};
title = "Childish Gambino - This Is America (Official Video)";
};
},

如您所见,频道标题是"音乐"。我怎样才能得到那个真正的频道标题?

从任何播放列表或视频中获取频道 ID,并使用频道 ID 和part='snippet'进行频道:列表 API 调用。结果将包含频道标题和其他详细信息。

示例网址:https://www.googleapis.com/youtube/v3/channels?id=UC_x5XG1OV2P6uZZ5FSM9Ttw&part=snippet&key=API_KEY

响应:

{
"kind": "youtube#channelListResponse",
"etag": ""DuHzAJ-eQIiCIp7p4ldoVcVAOeY/3xuQp_Bnwrc1tW3bBIDi6LxzB7I"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#channel",
"etag": ""DuHzAJ-eQIiCIp7p4ldoVcVAOeY/czbu6JihYqowBUI2jn5-PBL7TvY"",
"id": "UC_x5XG1OV2P6uZZ5FSM9Ttw",
"snippet": {
"title": "Google Developers",
"description": "The Google Developers channel features talks from events, educational series, best practices, tips, and the latest updates across our products and platforms.",
"customUrl": "GoogleDevelopers",
"publishedAt": "2007-08-23T00:34:43.000Z",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/a-/AJLlDp2JcYTd7j-M2CUsBC2zO-p6TVYo0bE8dsS_fw=s88-mo-c-c0xffffffff-rj-k-no",
"width": 88,
"height": 88
},
"medium": {
"url": "https://yt3.ggpht.com/a-/AJLlDp2JcYTd7j-M2CUsBC2zO-p6TVYo0bE8dsS_fw=s240-mo-c-c0xffffffff-rj-k-no",
"width": 240,
"height": 240
},
"high": {
"url": "https://yt3.ggpht.com/a-/AJLlDp2JcYTd7j-M2CUsBC2zO-p6TVYo0bE8dsS_fw=s800-mo-c-c0xffffffff-rj-k-no",
"width": 800,
"height": 800
}
},
"localized": {
"title": "Google Developers",
"description": "The Google Developers channel features talks from events, educational series, best practices, tips, and the latest updates across our products and platforms."
}
}
}
]
}

相关内容

  • 没有找到相关文章

最新更新