问题描述
首映式是直播和传统 YouTube 视频的混合体.详细说明:https://wersm.com/youtube-makes-premieres-available- 对所有人/
Premieres are a mix between a live stream and a traditional YouTube video. Detailed description: https://wersm.com/youtube-makes-premieres-available-to-everyone/
有没有办法通过 Youtube API 查找频道的首映?,有没有播放列表,类似于自动生成的直播播放列表(https://www.youtube.com/channel/UC4R8DWoMoI7CAwX8_LjQHig),只有首映?
Is there any way for finding premieres of a channel through Youtube API?, is there any playlist, similar to autogenerated playlists of live broadcasts (https://www.youtube.com/channel/UC4R8DWoMoI7CAwX8_LjQHig), only with premieres?
YouTube 搜索:列表端点(https://developers.google.com/youtube/v3/docs/search/list) 不包含此类视频的事件类型过滤器.仅包括即将到来的"和实时"事件过滤器,但它们不适用于首映.仅使用实时内容.
YouTube search:list end-point (https://developers.google.com/youtube/v3/docs/search/list) doesn't include a event type filter for this kind of video. Only includes "upcoming" and "live" event filters, but they don't work with premieres. Only work with live content.
提前致谢.
最好的问候.
推荐答案
我找到的唯一方法是:
使用带有频道 ID 过滤器的搜索端点来构建频道中所有将
liveBroadcastContent
设置为upcoming
的视频的列表.这将为您提供所有首映视频以及直播视频的列表.
Use the search endpoint with a channel id filter to build a list of all the videos in a channel that have
liveBroadcastContent
set toupcoming
. This will get you a list of all the premiere videos, as well as the livestreaming ones.
使用带有频道 ID 过滤器和 upcoming
的 eventType
过滤器的搜索端点.这将为您提供所有直播的列表.
Use the search endpoint with a channel id filter and an eventType
filter for upcoming
. This will get you a list of all livestreaming ones.
取两组id的差.
我刚刚测试过,它适用于我的频道,但我承认它在配额消耗方面相当昂贵.这不是一个很好的答案,但它是唯一的答案.:)
I just tested and it works for my channel, but I'll admit it's quite expensive in terms of quota consumption. It's not a great answer, but it's the only answer. :)
或者,如果可以对您的内容上传者施加一些限制,那么我建议您要求他们 1) 在视频说明中添加井号标签或 2) 将视频添加到特殊的、公开的但未列出的播放列表.这样,您的应用程序既可以搜索该哈希标签,也可以从该播放列表中读取,后者在配额消耗方面要便宜得多.
Alternatively, if it's possible to impose some restrictions on your content uploader, then I would suggest that you either ask them to 1) add their a hash tag in their video description or 2) add the video to a special, public but non-listed playlist. That way your application can either search for that hash tag or read from that playlist, the latter being much much cheaper for quota consumption.
另一种方法:
使用带有频道 ID 过滤器的搜索端点来构建频道中所有将
liveBroadcastContent
设置为upcoming
的视频的列表.这将为您提供所有首映视频以及直播视频的列表.
Use the search endpoint with a channel id filter to build a list of all the videos in a channel that have
liveBroadcastContent
set toupcoming
. This will get you a list of all the premiere videos, as well as the livestreaming ones.
将视频端点与您从上面收集的 id 列表一起使用,并确保将 contentDetails
作为 part
参数的一部分.您可以在此处查看视频的持续时间.它会像这样
Use the video endpoint with the list of ids that you have gathered from above, and be sure to put the contentDetails
as part of the part
parameter. You can see the duration of the video here. It will resemble something like this
"contentDetails": {
"duration": "P0D",
"dimension": "2d",
"definition": "sd",
"caption": "false",
"licensedContent": false,
"contentRating": {},
"projection": "rectangular"
},
这个视频绝对是即将到来的直播,因为它的持续时间为零P0D
.即将到来的首映已经有一个固定的非零持续时间.
This video is definitely an upcoming livestream, because it has a zero duration P0D
. The upcoming premieres already have a fixed non-zero duration.
- 保留所有持续时间不为零的视频.
这也可以.
这篇关于通过 Youtube API 寻找首映的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!