【问题标题】:How to use YouTube API to check if a video is restricted?如何使用 YouTube API 检查视频是否受到限制?
【发布时间】:2016-12-10 06:12:02
【问题描述】:

例如,当嵌入此 YouTube video 时,我们会收到 This video contains content from... who has blocked it from display on the website 错误消息。

如何使用 API 来判断视频是否被屏蔽?

我找到的最接近的参数是statuscontentDetails

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

不返回有关限制的指示:

   "contentDetails": {
    "duration": "PT2M",
    "dimension": "2d",
    "definition": "hd",
    "caption": "false",
    "licensedContent": true,
    "projection": "rectangular"
   },
   "status": {
    "uploadStatus": "processed",
    "privacyStatus": "public",
    "license": "youtube",
    "embeddable": true,
    "publicStatsViewable": false
   }

【问题讨论】:

标签: youtube-data-api


【解决方案1】:

检查是否在contentDetails.regionRestriction地区受限或有年龄限制的内容contentDetails.contentRating或合作伙伴声明的内容contentDetails.licensedContent?我也只是在这里猜测。

编辑:您可以使用它来检查它是否也可嵌入status.embeddable

【讨论】:

  • status 和 contentDetails 都没有显示任何限制指示。我已经更新了问题以使其更清楚,谢谢。
  • 您可以直接从浏览器访问视频吗?
  • 该视频在浏览器 (youtube.com) 中对我来说很好。并且您的状态响应显示 embeddable=true。我想我想不通,对不起!祝你好运!
  • 您是否点击了问题中的链接并播放了视频?
  • 我在尝试查看来自日本的示例嵌入视频时看到了您的错误消息。地理锁定?
【解决方案2】:

确保正确设置“部分”。这是一个必填字段,您可能有“sn-p there”并且您需要“contentDetails”。 (或两者的“sn-p,contentDetails”)

例子:

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


{
 "kind": "youtube#videoListResponse",
 "etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/Xn7P-qyclepPOIFp9Bn69FdtR-4\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 1
 },
 "items": [
  {

   "kind": "youtube#video",
   "etag": "\"XpPGQXPnxQJhLgs6enD_n8JR4Qk/_vu8XkjotVqxtJKQ2peTcRK8TYE\"",
   "id": "OoKpYXTmYak",
   "contentDetails": {
    "duration": "PT1M41S",
    "dimension": "2d",
    "definition": "hd",
    "caption": "false",
    "licensedContent": true,
    "regionRestriction": {
     "allowed": [
      "ES",
      "US"
     ]
    },
    "projection": "rectangular"
   }
  }
 ]
}

这仅在美国和西班牙允许

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-08
    • 2021-05-03
    • 2015-10-08
    • 2015-08-10
    • 2015-07-23
    • 2014-12-13
    • 2020-07-13
    相关资源
    最近更新 更多