0

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

谢谢你的帮助。

4

1 回答 1

0

您可以使用 YouTube Data 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.
于 2013-10-30T13:59:44.850 回答