如何检索与订阅相关联的YouTube视频

时间:2015-08-26 13:41:44

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

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

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。检索与订阅相对应的频道

将其输入playlists.list api

  

channelId字符串   此值表示API应仅返回指定频道的播放列表。

我们得到了

{
 "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 PLwwBPMOKYX3PfjOwByTLJMeMKE48ybU2m

3。检索与频道对应的播放列表项

将其输入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用于检索订阅下的默认视频列表的公式是什么?

0 个答案:

没有答案