如何使用YouTube API中的LiveBroadcasts:list? [英] How do I use LiveBroadcasts:list from YouTube API?

查看:113
本文介绍了如何使用YouTube API中的LiveBroadcasts:list?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用YouTube API进行直播.但是,我没有任何结果.这是我的工作:

I'm trying to use YouTube API for Live Broadcasts. But, I don't get any results. Here's what I do:

  1. 转到#Live YouTube频道:

  1. Go to #Live YouTube channel:

www youtube com channel / UC4R8DWoMoI7CAwX8_LjQHig

  • 打开任何实时广播以获取广播ID(例如"CGt1Ac1gEZc").

  • Open any Live Broadcast to get Broadcast ID (for example, "CGt1Ac1gEZc").

    尝试在irb中使用此广播ID:

    Try to use this Broadcast ID in irb:

    irb(main):038:0> list = youtube.list_live_broadcasts("id,snippet,contentDetails,status", id: "CGt1Ac1gEZc")
    => #<Google::Apis::YoutubeV3::ListLiveBroadcastsResponse:0x0000000546a960 @etag="\"oqbvhYxBE6fAbRk6m7aLlHf5s1I/P7sEkFelJCqPWY-5t7EUKYER_MQ\"", @items=[], @kind="youtube#liveBroadcastListResponse", @page_info=#<Google::Apis::YoutubeV3::PageInfo:0x000000054634d0 @results_per_page=5, @total_results=0>>
    irb(main):039:0> list.items.inspect
    => "[]"
    

  • 如您所见,@items数组为空.

  • As you see, the @items array is empty.

    打开 https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/list 尝试在那里获取数据,但仍然一无所获(请参见图片): http://i.imgur.com/6KTr1YS.png

    Open https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/list to try to get data there, but still nothing (see image): http://i.imgur.com/6KTr1YS.png

    仍然为空的@items数组. 即使此广播是100%在线的,我还是尝试按所有"广播进行过滤,结果是相同的:没有找到项目.

    Still, empty @items array. Even though this broadcast is 100% online, I tried filtering by "all" broadcasts, the result is the same: no items found.

    这是我的错还是YouTube API发生了什么事?

    Is this my fault or something happened to YouTube API?

    推荐答案

    该查询返回了0个项目,因为 liveBroadcasts/list 终结点仅可用于通过您的身份验证创建的频道的广播.您不能使用list端点来检索有关其他任何人的广播的信息.

    That query is returning 0 items because the liveBroadcasts/list endpoint can only be used for broadcasts that the channel your are authenticated as has created. You cannot use the list endpoint to retrieve information about anyone else's broadcast.

    如果要检索其他频道的广播信息,则必须使用标准的

    If you want to retrieve information on another channel's broadcast, you have to use the standard Search/list endpoint. This will return return only live events from a particular channel, without being authenticated as that channel/user, if you know that channel's channelId:

    part -> snippet

    channelId-> [channelId of the channel/user with the live event]

    eventType -> live

    type -> video(将eventType设置为live时必需)

    HTTP GET https://www.googleapis.com/youtube/v3/search?part=snippet&channelId={channelId}&eventType=live&type=video&key={YOUR_API_KEY}
    

    这篇关于如何使用YouTube API中的LiveBroadcasts:list?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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