objective-c - 如何检索与订阅相关的 youtube 视频

标签 objective-c youtube youtube-api youtube-data-api youtube-channels

youtube data api 中不清楚如何立即显示与用户订阅相关的视频。例如,在 youtube iOS 客户端(版本 10.31.11670)中,假设我点击我的 aarmin van buren 订阅。它会立即在其下显示一个视频列表(还有一个视频选项卡):

enter image description here

enter image description here

enter image description here

从 youtube 数据 api.. 我可以执行以下操作:

1. 检索用户的订阅

使用 YouTube subscription api对于我们得到的用户(除其他外):

 {

   "kind": "youtube#subscription",
   "etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/JMhno_Wae-hxWVRKTkIpLhQybR4\"",
   "id": "jdBPZ2FSEH2Q9kFmXaAiv0HFD6yePlK2vhWiM86Jn5s",
   "snippet": {
    "publishedAt": "2015-08-25T14:22:33.000Z",
    "title": "Moretoki",
    "description": "Here's my channel for random vlogs, skits, challenges, tags, collabs and other shenanigans.\n\nSend me stuff if you want:\nMotoki Maxted\nP.O. Box 257\nWauseon, Ohio 43567",
    "resourceId": {
     "kind": "youtube#channel",
     "channelId": "UCPvyOQD9hxY8433PN9QalIg"
    },
    "channelId": "UCuYVSPi09ZCcjxzUEVa4Geg",
    "thumbnails": {
     "default": {
      "url": "https://yt3.ggpht.com/-0yxR0ez3Cts/AAAAAAAAAAI/AAAAAAAAAAA/wyjHkDa5MUg/s88-c-k-no/photo.jpg"
     },
     "high": {
      "url": "https://yt3.ggpht.com/-0yxR0ez3Cts/AAAAAAAAAAI/AAAAAAAAAAA/wyjHkDa5MUg/s240-c-k-no/photo.jpg"
     }
    }
   },

所以从上面我们有channelID UCPvyOQD9hxY8433PN9QalIg

2. 检索订阅对应的 channel

将其输入 playlists.list api

channelId string This value indicates that the API should only return the specified channel's playlists.



我们得到
{
 "kind": "youtube#playlistListResponse",
 "etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/uGzAgLKA3x8AEd-nxyJ5lhZcxSs\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 5
 },
 "items": [
  {

   "kind": "youtube#playlist",
   "etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/eVp7hvk1O_j60JIxT7FuF4W4NKs\"",
   "id": "PLwwBPMOKYX3PfjOwByTLJMeMKE48ybU2m",
   "snippet": {
    "publishedAt": "2014-07-09T15:31:56.000Z",
    "channelId": "UCPvyOQD9hxY8433PN9QalIg",
    "title": "VidCon 2014",
    "description": "",
    "thumbnails": {

所以我们有一个播放列表ID PLw​​wBPMOKYX3PfjOwByTLJMeMKE48ybU2m

3.检索 channel 对应的播放列表项

将其输入 playlistItems.list我们得到的api
"items": [
  {

   "kind": "youtube#playlistItem",
   "etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/CzkXHmWO1vOcEsZzjsWrqhuMFbc\"",
   "id": "PLJrD1EGFW0r-lGr4519_DEUl6_eusNtNEcusKszRfKl4",
   "snippet": {
    "publishedAt": "2014-07-09T15:36:03.000Z",
    "channelId": "UCPvyOQD9hxY8433PN9QalIg",
    "title": "CALIFORNIA ADVENTURE",
    "description": "Day 1 of my California/Vidcon vlogs\n\nNext vlog - http://youtu.be/4J8wUIK-bzM\nLast vlog - http://youtu.be/7DyTydTCMJU\nKenny's collab - http://youtu.be/ATEu1Tk2pys\n\nYouTubers in the video!\nhttps://www.youtube.com/PointlessBlog\nhttps://www.youtube.com/callux\nhttps://www.youtube.com/jeffreyfever\nhttps://www.youtube.com/edsta\nhttps://www.youtube.com/iamKennyBrown\nhttps://www.youtube.com/sxephil\nhttps://www.youtube.com/TheOliWhiteTV\nhttps://www.youtube.com/jameschats\nhttps://www.youtube.com/benwillingdorf\nhttps://www.youtube.com/panopancakes\nhttps://www.youtube.com/tayzonday\nhttps://www.youtube.com/wtffilmsftw\nhttps://www.youtube.com/mysteryguitarman\nhttps://www.youtube.com/mikeybolts\n\n\nMain Channel - http://youtube.com/motokimaxted\nTwitter - http://twitter.com/motokimaxted\nInstagram - http://instagr.am/motokimaxted\nFacebook - http://facebook.com/motokimaxted\nTumblr - http://motokimaxted.tumblr.com\nVine - https://vine.co/motokimaxted\n\nSpecial thanks to the music with sick summer vibes by:\nhttps://soundcloud.com/thecancel\nhttps://soundcloud.com/thebeatknitter\nhttps://soundcloud.com/whoisqueen",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/H4yPmh2C_08/default.jpg",
      "width": 120,
      "height": 90

所以我的问题是:我怎样才能通过订阅 ID 获得视频列表?或者至少我想知道 youtube 用来检索订阅下的默认视频列表的公式是什么?

最佳答案

事实证明,有一条更简单的路径.. 从用户订阅调用中检索到 channelId 后(请参阅上面有问题的第 1 部分.. channel id 是 UCPvyOQD9hxY8433PN9QalIg )我们可以将其用作 channel ID youtube search api 中的参数(并添加片段作为 部分 参数).. 结果如下所示:

{
 "kind": "youtube#searchListResponse",
 "etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/dhO9gkvzsSRnS_UX-4W-XrFxiPc\"",
 "nextPageToken": "CAUQAA",
 "pageInfo": {
  "totalResults": 27,
  "resultsPerPage": 5
 },
 "items": [
  {
   "kind": "youtube#searchResult",
   "etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/_11G-M9NjTm9Sc-HOgRE7MjzVJU\"",
   "id": {
    "kind": "youtube#video",
    "videoId": "Nx1a1aTcSGk"
   },
   "snippet": {
    "publishedAt": "2015-06-02T02:40:52.000Z",
    "channelId": "UCPvyOQD9hxY8433PN9QalIg",
    "title": "Songs in Real Life Spring Edition",
    "description": "High school students live their lives singing modern hit songs. Watch the first one - https://youtu.be/LRPUtpiKnKU Snapchat - MotokiMaxted Main ...",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/vi/Nx1a1aTcSGk/default.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/vi/Nx1a1aTcSGk/mqdefault.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/vi/Nx1a1aTcSGk/hqdefault.jpg"
     }
    },
    "channelTitle": "moretoki",
    "liveBroadcastCo
    ...

关于objective-c - 如何检索与订阅相关的 youtube 视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32228323/

相关文章:

android - 如何在 YouTube 中播放私有(private)视频?

youtube - 使用 Youtube v3 api 无法获取内容详细信息或持续时间

iphone - 当我在顶部使用 TabBarController 时在底部显示空白

objective-c - 获取 iOS 支持的货币列表

objective-c - 改进在文本正文中查找 URL 的算法 - obj-c

css - 覆盖来自 YouTube 的外部 CSS

ios - 可以填充选择器 View 但不能从中获取数据

android - 使用Intent的Youtube播放列表,不显示对话框

php - 如何为PECL bbcode扩展创建[youtube] -Tag?

c# - 在YouTube C#.net中用于视频上传的Google Developer API V3