gpt4 book ai didi

youtube - 检查视频是否可用

转载 作者:行者123 更新时间:2023-12-04 15:42:52 25 4
gpt4 key购买 nike

我正在使用YouTube数据API v3。

我想知道如何检查视频是否已被YouTube禁用或删除。

例如:
https://www.youtube.com/watch?v=dHt_6Z2OaZI

https://www.googleapis.com/youtube/v3/videos?id=dHt_6Z2OaZI
&part=snippet,contentDetails,player,statistics,status
&key=[mykey]

我无法从API中获得任何想法。
{
"kind": "youtube#videoListResponse",
"etag": "\"iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/Y7032cCbQSAurzEiVMjdFYzamtg\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/2FORRsUGqbS1nvQK3AR1PfmiN7I\"",
"id": "dHt_6Z2OaZI",
"snippet": {},
"contentDetails": {
"duration": "PT1H31M1S",
"dimension": "2d",
"definition": "sd",
"caption": "false",
"licensedContent": false
},
"status": {
"uploadStatus": "processed",
"privacyStatus": "public",
"license": "youtube",
"embeddable": true,
"publicStatsViewable": true
},
"statistics": {
"viewCount": "301",
"likeCount": "0",
"dislikeCount": "0",
"favoriteCount": "0",
"commentCount": "0"
},
"player": {
"embedHtml": "<iframe width=\"640\" height=\"360\" src=\"//www.youtube.com/embed/dHt_6Z2OaZI\" frameborder=\"0\" allowfullscreen></iframe>"
}
}
]
}

我试过了
https://www.googleapis.com/youtube/v3/videos
?part=id
&key=[mykey]
&id=dHt_6Z2OaZI

但这不起作用,仍然给出结果。

最佳答案

您发布的结果中有一个status字段。我认为与您想要的内容最紧密相关的子字段是uploadStatus。当我对该视频执行API调用时,我得到:

"status": {
"uploadStatus": "rejected",
"rejectionReason": "uploaderAccountSuspended",
"privacyStatus": "public",
"license": "youtube",
"embeddable": true,
"publicStatsViewable": true
}

documentation中,这是 uploadStatus的可能值:

  • deleted
  • failed
  • processed
  • rejected
  • uploaded


视频成功上传并处理后,用户应该可以访问它(假定它也是公开的)。因此,您应该只检查状态是“已拒绝”还是“已删除”。

关于youtube - 检查视频是否可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31461883/

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