YouTube 数据 API v3 嵌入页面不起作用 https://www.youtube.com/embed/TjI3bzvbCU4 .
而对于像这样的其他视频(ZqYezph-hgg
) it works https://www.youtube.com/embed/ZqYezph-hgg.
所以我的想法只是检索https://www.youtube.com/embed/VIDEO_ID https://www.youtube.com/embed/VIDEO_ID看看视频是否无法播放,例如:
curl -s https://www.youtube.com/embed/TjI3bzvbCU4 | grep "UNPLAYABLE" | wc -l
Returns 1
,所以该视频无法播放。
curl -s https://www.youtube.com/embed/ZqYezph-hgg | grep "UNPLAYABLE" | wc -l
Returns 0
,所以该视频是可以播放的。
另请注意,我的开源 https://github.com/Benjamin-Loison/YouTube-operational-API/blob/c8e59bfd5ec4f7aae67e0069f565585f794287ee/videos.php#L100 YouTube 操作 API https://github.com/Benjamin-Loison/YouTube-operational-API更正确地实现此功能,如返回:
{
"kind": "youtube#videoListResponse",
"etag": "NotImplemented",
"items": [
{
"kind": "youtube#video",
"etag": "NotImplemented",
"id": "TjI3bzvbCU4",
"status": {
"embeddable": true,
...
}
}
]
}
and 返回:
{
"kind": "youtube#videoListResponse",
"etag": "NotImplemented",
"items": [
{
"kind": "youtube#video",
"etag": "NotImplemented",
"id": "ZqYezph-hgg",
"status": {
"embeddable": true,
...
}
}
]
}