如何在 YouTube 上检索直播活动的开始时间? [英] How to retrieve the start time of a live event on YouTube?

查看:62
本文介绍了如何在 YouTube 上检索直播活动的开始时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试返回并同步已完成或正在进行的实时事件与现实世界的时间戳(例如,推特逐个播放).我不拥有相关的实时事件.显然,这仅适用于可以倒带或重播的事件(例如许多与游戏相关的广播)

I'm trying to go back and sync completed or in-progress live event with real-world timestamps (for example, a twitter play-by-play.) I don't own the live events in question. Obviously this is only useful for events that can be rewound or replayed (such as many of the gaming-related broadcasts)

有没有办法检索直播活动的开始时间?

Is there a way to retrieve the start time of a live event?

我尝试了以下方法:

使用 player.getDuration():

Using player.getDuration():

如果当前播放的视频是直播事件,getDuration() 函数将返回自直播视频流开始以来经过的时间.具体来说,这是视频在没有重置或中断的情况下流式传输的时间量.此外,此持续时间通常比实际事件时间长,因为流式传输可能会在事件开始时间之前开始.

If the currently playing video is a live event, the getDuration() function will return the elapsed time since the live video stream began. Specifically, this is the amount of time that the video has streamed without being reset or interrupted. In addition, this duration is commonly longer than the actual event time since streaming may begin before the event's start time.

这似乎并不总是准确的 - 如果直播活动具有设定的广播持续时间,这似乎反而返回了安排广播的总时间.这是一个展示这种行为的随机视频:http://www.youtube.com/watch?v=e-Bb5F8Jcwg(通过 http://www.youtube.com/live/找到)全部)

This doesn't seem to be always accurate - if a live event has a set broadcast duration, this seems to instead return the total time that the broadcast is scheduled for. here is a random video that exhibits that behaviour: http://www.youtube.com/watch?v=e-Bb5F8Jcwg (found via http://www.youtube.com/live/all)

我也尝试过使用数据 api 并从代码片段中获取发布时间,但这通常看起来是在广播实际开始前几个小时或几天.

I've also tried using the data api and grabbing the publish time from the snippet, but this usually appears to be a few hours or days before the broadcast actually begins.

作为非内容拥有者,这次有没有办法找回?

As a non-content owner, is there any way to retrieve this time?

谢谢!


进一步查看后,我找到了 developer.google.com/youtube/2.0/... 它似乎在每个事件的 yt:when 下提供此信息...所以我想我修改后的问题是 - 有没有办法检索这个给定视频 ID,还是我总是需要通过实时事件 api 找到它?


After looking further, I found developers.google.com/youtube/2.0/… which appears to offer this information under the yt:when for each event... so I guess my revised question would be - is there a way to retrieve this given a video ID, or do I always need to find it through the live events api?

推荐答案

您可以使用 Data API v3 为此.

您可以使用 id=VIDEO_ID 执行 videos->list

You can do a videos->list with id=VIDEO_ID

您可以从 contentDetails.duration 中获取持续时间回复.

You can get duration from contentDetails.duration from the response.

如果内容是您自己的,您可以使用 v3 Live Streaming API这个.

If the content was your own, you could use v3 Live Streaming API for this.

您可以使用 id 执行 liveBroadcasts->list=VIDEO_ID

You can do a liveBroadcasts->list with id=VIDEO_ID

您可以使用 snippet.actualStartTime 计算持续时间和响应中的 snippet.actualEndTime.

You can calculate duration with snippet.actualStartTime and snippet.actualEndTime from the response.

这篇关于如何在 YouTube 上检索直播活动的开始时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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