如何检查 YouTube 视频是否被阻止/限制/删除 [英] How do I check if a youtube video is blocked/restricted/deleted

查看:101
本文介绍了如何检查 YouTube 视频是否被阻止/限制/删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储用户播放列表的网站,但有时曾经可用的视频会因侵犯版权而被删除或被删除.我希望我的网站在发生这种情况时自动检测,以便删除或替换视频.我做了很多研究试图解决这个问题,但没有任何效果.例如,YouTube 视频 ID IcmTyiVkhGk(由于版权不可用)的 api 数据请求没有 yt:state 变量(表示它受到限制),在访问控制下,它不会说受限制或任何东西相似的.您如何检查此类数据?

I have a website that stores users playlists, but sometimes the videos that were once usable get removed due to copyright violations, or get deleted. I would like my website to automatically detect when this happens, so it can delete the video, or replace it. I'v done a lot of research trying to figure this out but nothing is working. for example, the api data request for the youtube video ID IcmTyiVkhGk (which is unavailable due to copyright) doesn't have a yt:state variable (which would indicate it is restricted), under access control, it does not say restricted or anything similar. How do you check for this type of data?

http://gdata.youtube.com/feeds/api/videos/IcmTyiVkhGk?v=2&prettyprint=true

基本上使用它来获取数据,但我认为没有相关数据.

basically using this to get the data, but no relevant data is there I don't think.

该站点能够检测该站点在哪些区域可用:http://polsy.org.uk/stuff/ytrestrict.cgi?ytid=IcmTyiVkhGk有谁知道这是如何工作的?

this site is able to detect what regions the site is available in: http://polsy.org.uk/stuff/ytrestrict.cgi?ytid=IcmTyiVkhGk Does anyone know how this works?

推荐答案

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

您的问题分为两部分.

  1. 要检查视频是否已从 YouTube 中删除,请发送包含视频 ID 的视频:列表请求.对于单个 ID,您只需检查 totalResults 是否为 0.如果一次检查多个视频 ID,请循环查看项目响应以查看 YouTube 上仍存在哪些视频 ID.

示例:

GET https://www.googleapis.com/youtube/v3/videos?part=id&id=abcdefghijklm&key={YOUR_API_KEY}

{
 "kind": "youtube#videoListResponse",
 "etag": "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/qFRkUhSdCF83BrjXm7uub8slGsk\"",
 "pageInfo": {
  "totalResults": 0,
  "resultsPerPage": 0
 },
 "items": [
 ]
}

  1. 要检查访问限制,请发送视频:内容详细信息列表请求.

示例:

GET https://www.googleapis.com/youtube/v3/videos?part=contentDetails&id=IcmTyiVkhGk&key={YOUR_API_KEY}

在 items[] 下你会检查

Under items[] you'll check for

 "regionRestriction": {
 "blocked": [
  "QA",
  "AW",
  "IN",
  etc.
  ]
  }

这篇关于如何检查 YouTube 视频是否被阻止/限制/删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆