在YouTube api中从自动生成的频道中获取视频 [英] Fetching videos from auto generated channel in YouTube api

查看:195
本文介绍了在YouTube api中从自动生成的频道中获取视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从YouTube自动生成的频道获取所有视频(AKA主题)。
我让我的用户添加一个链接到YT频道,并发送频道ID来检索视频。



在常规情况下,当频道不是自动生成我正在使用此端点:$ b​​ $ b https:/ /www.googleapis.com/youtube/v3/channels?part=snippet&channelId= {channel_id}& key = {key}



此终点返回发布到此频道的视频列表。
主题的问题在于视频列表返回空...



以下请求的示例:
https://www.googleapis.com/youtube / v3 / search?part = snippet& channelId = UCYF2FotHeGO6cNcldrTHN1g& key = {YOUR_API_KEY}

  {
样: YouTube的#searchListResponse,
的etag: \ 3enKTWw-I-yugKAPnlrhH5U04vQ / Zi7b6FbLUH9xd8vhDiVs3zpfKLs\ ,
pageInfo:{
使用totalResults :1,
resultsPerPage:5
},
items:[
{
kind:youtube#searchResult,
ETAG: \ 3enKTWw-I-yugKAPnlrhH5U04vQ / dkWBa22byHoKTpuDJQLPs5T6ndg\ ,
标识:{
种: YouTube的#槽钢,
的channelID :UCYF2FotHeGO6cNcldrTHN1g
},
snippet:{
publishedAt:2013-12-21T05:18:21.000Z,
channe lId:UCYF2FotHeGO6cNcldrTHN1g,
title:曼联F.C. - 主题,
描述:曼联足球俱乐部是一家英国足球俱乐部,总部设在大曼彻斯特的老特拉福德。俱乐部成立为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
}
}
]
}

任何想法如何获得主题视频?



谢谢

解决方案

我有一个类似的问题。



频道是直播频道
https://www.youtube.com/channel/UC4R8DWoMoI7CAwX8_LjQHig

我现在所做的是使用以下v3 API
https://开头www.googleapis.com/youtube/v3/channelSections?part=snippet%2C+contentDetails&channelId=UC4R8DWoMoI7CAwX8_LjQHig&hl=zh-TW&key= {YOUR_API_KEY}


$ b $我们可以用contentDetails获得很多项目:

 contentDetails:{
播放列表:[
PLU12uITxBEPEEIlLMEWFXvAeoZl0cSrok
]
}

然后我们可以请求PlaylistItemsAPI来获取每个播放列表的视频。



它可以与普通频道一起获取主页信息。
然而,对于Live频道,它确实会返回一些内容,但与浏览器(Chrome)的结果不同。



我想知道是解析YouTube自动生成频道的视频的更好解决方案。


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

解决方案

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 .

这篇关于在YouTube api中从自动生成的频道中获取视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆