使用 YouTube Data API 将视频识别为广告
我主要使用视频和搜索列表资源类型。我想过滤视频广告的结果。我本来希望广告是一个视频类别,或者视频广告有另一个标识符,但到目前为止我还没有找到方法。有什么想法吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我主要使用视频和搜索列表资源类型。我想过滤视频广告的结果。我本来希望广告是一个视频类别,或者视频广告有另一个标识符,但到目前为止我还没有找到方法。有什么想法吗?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
不幸的是(AFAIK),其中一些广告视频是不公开视频 - 请参阅这些 (1 和 2) 我在观看随机 YouTube 视频时提取的广告视频示例 - 此 广告视频是公开的。
查询其中一个视频的数据时(即
uuh2wkRmodI
) - 查看 API 文档中使用试用功能的示例 - ,我没有看到任何相关信息表明这是一个广告视频 - 除了是一个不公开的视频。也许,你可以考虑它的统计数据 - 我发现奇怪的是,一个视频没有喜欢,没有收藏,没有评论,并且有观看次数:
由于这些是不公开的广告视频,因此无法通过 API 进行搜索。 引用:
除非您以某种方式设法获取在正常视频开始之前出现的这些广告的
VIDEO_ID
,否则您无法通过 YouTube 或其 API 真正搜索这些视频。我的额外猜测是,这些广告视频也是由 YouTube 本身在观看者所在地区(国家)设置的(除了其他设置),并且这些广告视频的所有者付费YouTube 嵌入他们的广告。
如果您想尝试一下,请尝试搜索来自知名产品品牌渠道的视频,并仅获取他们的公开视频和某种短视频(我不是在谈论#shorts,但是,持续时间为一分钟半或更短的视频)。
此外,请考虑到某些广告视频可能会更长,因此,在简历中:您必须使用公开的内容。
Unfortunately (AFAIK), some of those ads videos are unlisted videos - see these (1 and 2) ads videos examples I extracted while watching a random YouTube video - this ads video is public, though.
While querying the data of one of these videos (i.e.
uuh2wkRmodI
) - see the example using the try-it feature in the API documentation - , I don't see any relevant information that points me this is an advertisement video - other than being an unlisted video.Probably, you can consider its statistics - I found odd that a video has no likes, no favorites no comments AND has views:
Since those are unlisted ads videos, those cannot be searched via the API. Quote:
Unless you somehow manages to get the
VIDEO_ID
s of those ads appearing before a normal video starts, you cannot really search those videos neither by YouTube or its API.My additional guess is also those ads videos are set by YouTube itself based (aside other settings) in the region (country) of the viewer and the owner of those ads videos pays to YouTube for embed their advertisements.
If you want to try it out, then, try to search for videos that came from channels of recognized product brands and get only their public and kind of short videos (I'm not talking abuot #shorts, but, videos with a duration of a half on a minute or less).
Additionally, take into account that some ads videos might be longer, so, in resume: you have to work with what is publicly available.
使用我的开源 < a href="https://yt.lemnoslife.com" rel="nofollow noreferrer">YouTube 操作 API 您可以通过在 https://yt.lemnoslife.com/videos?part=isPaidPromotion&id=VIDEO_ID
以下是视频 ID 示例:
PEorJqo2Qaw
Q6gtj1ynstU
然后你必须发现全部 YouTube 视频,除非您寻找特定的关键字等,否则有这种困难的方法,其中包括获取初始的 YouTube 频道集,获取他们的视频,获取每个视频的评论,从评论中获取 YouTube 频道等等。
With my open-source YouTube operational API you have access to whether or not a given video is a paid promotion by fetching the
isPaidPromotion
boolean in the JSON file at https://yt.lemnoslife.com/videos?part=isPaidPromotion&id=VIDEO_IDHere are examples of videos ids:
PEorJqo2Qaw
Q6gtj1ynstU
Then you have to discover all YouTube videos, to do so except if you look for specific keywords etc, there is this difficult method which consists in getting an initial set of YouTube channels, fetching their videos, fetching the comments on each video, fetching the YouTube channels from the comments and so on.