gpt4 book ai didi

jquery - 检测是否将youtube视频嵌入到我的网页中

转载 作者:行者123 更新时间:2023-12-03 06:32:00 24 4
gpt4 key购买 nike

如果我在网页上嵌入了youtube视频,是否可以使用jquery / javascript来检测视频是否关闭(由于版权或用户关闭了视频)?

谢谢你的帮助。

最佳答案

您可以使用YouTube数据API v3使用javascript检索视频数据:

https://developers.google.com/youtube/v3/docs/videos

您可以检查视频是否存在,尝试检索视频数据:

https://developers.google.com/youtube/v3/docs/videos/list

在检索视频数据后,您可以验证以下字段:

contentDetails.regionRestriction

The regionRestriction object contains information about the countries where a video is (or is not) viewable. The object will contain either the contentDetails.regionRestriction.allowed property or the contentDetails.regionRestriction.blocked property.

contentDetails.regionRestriction.allowed[]

A list of region codes that identify countries where the video is viewable. If this property is present and a country is not listed in its value, then the video is blocked from appearing in that country. If this property is present and contains an empty list, the video is blocked in all countries.

contentDetails.regionRestriction.blocked[]

A list of region codes that identify countries where the video is blocked. If this property is present and a country is not listed in its value, then the video is viewable in that country. If this property is present and contains an empty list, the video is viewable in all countries.

关于jquery - 检测是否将youtube视频嵌入到我的网页中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19654368/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com