有没有办法让播放列表使用youtube api计算

时间:2017-03-07 14:05:36

标签: youtube-api playlists

朋友们正在尝试使用youtube api使用channelid获取频道中播放列表的确切数量。

1 个答案:

答案 0 :(得分:0)

是的,可以使用Youtube V3 APIplaylist.list以及频道ID。

Get all playlist ids from channel id - youtube api v3显示了如何从API中获取播放列表ID。

通过API资源管理器发送的请求:

part: snippet
channelId: UCBkNpeyvBO2TdPGVC_PsPUA

来自playlist.list

的回复
{
 "kind": "youtube#playlistListResponse",
 "etag": "\"uQc-MPTsstrHkQcRXL3IWLmeNsM/GayOzLnLt1ndQVz5WvCaYWPuXUo\"",
 "nextPageToken": "CAUQAA",
 "pageInfo": {
  "totalResults": 14, <--- Total number of playlists.
  "resultsPerPage": 5
 },
 "items": [
  {
   "kind": "youtube#playlist",
   "etag": "\"uQc-MPTsstrHkQcRXL3IWLmeNsM/llWSSTxPt1F74kWJeadntx0oOlU\"",
   "id": "PL2qcutlDmS0BGjOf5rwjWNH6JnyFEShyb",
   "snippet": {
     // snippet information, title etc
   }
  },
  {
   "kind": "youtube#playlist",
   "etag": "\"uQc-MPTsstrHkQcRXL3IWLmeNsM/D7iFaGmnjkkw29IXm-6kWaCd0a8\"",
   "id": "PL2qcutlDmS0DUCGOdr5eYDwZC_1JAReI4", 
   "snippet": {
  },
  {
   "kind": "youtube#playlist",
   "etag": "\"uQc-MPTsstrHkQcRXL3IWLmeNsM/0MGgZUqxHh3qkYePoEP3C9ZPamU\"",
   "id": "PL2qcutlDmS0DMB6Xv2KmlKzdOtNqMOwpv", // Count 3
   "snippet": {
        // snippet information, title etc
    }
  },
  {
   "kind": "youtube#playlist",
   "etag": "\"uQc-MPTsstrHkQcRXL3IWLmeNsM/XMQu1lYA_nJGBD5l7JknPncuwv0\"",
   "id": "PL2qcutlDmS0CnyV8Jcbl2d7yFxd2iGg67",
   "snippet": {
        // snippet information, title etc
   }
  }
 ]
}

您可以使用totalResults中的pageInfo来获取该频道的播放列表数量。