检测是否将YouTube视频嵌入我的网页

时间:2013-10-29 09:33:48

标签: jquery youtube youtube-api

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

感谢您的帮助。

1 个答案:

答案 0 :(得分: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.