Fetching videos from auto generated channel in YouTube api

感情迁移 提交于 2019-12-05 03:38:45

问题


Im trying to get all videos from YouTube auto-generated channel (AKA Topic). I let my users add a link to the YT channel and I am sending the channel ID to retrieve videos.

On regular case, when the channel is NOT auto-generate I am using this endpoint: https://www.googleapis.com/youtube/v3/channels?part=snippet&channelId={channel_id}&key={key}

This endpoint return a list of videos that posted into this channel. The problem with topic is that the list of videos return empty...

example for this following request: https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCYF2FotHeGO6cNcldrTHN1g&key={YOUR_API_KEY}

{
 "kind": "youtube#searchListResponse",
 "etag": "\"3enKTWw-I-yugKAPnlrhH5U04vQ/Zi7b6FbLUH9xd8vhDiVs3zpfKLs\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 5
 },
 "items": [
  {
   "kind": "youtube#searchResult",
   "etag": "\"3enKTWw-I-yugKAPnlrhH5U04vQ/dkWBa22byHoKTpuDJQLPs5T6ndg\"",
   "id": {
    "kind": "youtube#channel",
    "channelId": "UCYF2FotHeGO6cNcldrTHN1g"
   },
   "snippet": {
    "publishedAt": "2013-12-21T05:18:21.000Z",
    "channelId": "UCYF2FotHeGO6cNcldrTHN1g",
    "title": "Manchester United F.C. - Topic",
    "description": "Manchester United Football Club is an English football club based in Old Trafford, Greater Manchester. The club was formed as Newton Heath LYR Football ...",
    "thumbnails": {
     "default": {
      "url": "https://i.ytimg.com/i/YF2FotHeGO6cNcldrTHN1g/1.jpg"
     },
     "medium": {
      "url": "https://i.ytimg.com/i/YF2FotHeGO6cNcldrTHN1g/mq1.jpg"
     },
     "high": {
      "url": "https://i.ytimg.com/i/YF2FotHeGO6cNcldrTHN1g/hq1.jpg"
     }
    },
    "channelTitle": "",
    "liveBroadcastContent": "none"
   }
  }
 ]
}

Any idea how to get Topic videos?

Thanks


回答1:


auto generated channels has not videos. They have only playlists with videos from other channels. so you have to look for playlists.




回答2:


I have a similar work like this issue.

My target channel is "Live" channel (https://www.youtube.com/channel/UC4R8DWoMoI7CAwX8_LjQHig)

What I have done for now is using the following v3 API https://www.googleapis.com/youtube/v3/channelSections?part=snippet%2C+contentDetails&channelId=UC4R8DWoMoI7CAwX8_LjQHig&hl=zh-TW&key={YOUR_API_KEY}

We can get many items with the part as "contentDetails"

"contentDetails": {
  "playlists": [
   "PLU12uITxBEPEEIlLMEWFXvAeoZl0cSrok"
  ]
}

And then we can request "PlaylistItems" API to get videos for each playlist.

It works with normal channels to get its homepage information. However, for "Live" channel, it does return something, but differs from the browser's (Chrome's) results.

I'd want to know if there is a better solution of parsing videos for YouTube auto-generated channel .



来源:https://stackoverflow.com/questions/24506417/fetching-videos-from-auto-generated-channel-in-youtube-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!