我想获取视频的频道名称,但它会给出播放列表的名称。我目前正在使用此网址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 America\U201d by Childish Gambino http://smarturl.it/TcIgA\nDirector: Hiro Murai\nProducer: Jason Cole of Doomsday with Ibra Ake and Fam Rothstein of Wolf + Rothstein\ntour 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)";
};
},
正如您所看到的,channelTitle是“音乐”。我怎样才能获得真正的channelTitle?
答案 0 :(得分:0)
从任意播放列表或视频中获取channelID,并使用channelID和part='snippet'
制作Channels:list API call。结果将包含频道标题和其他详细信息。
示例网址: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."
}
}
}
]
}