我们正在寻找一种方法来检查视频的YouTube URLS长长的列表,这些视频现在是私有的,已经被删除,或者其他原因不再可用。我们可以检查状态,但即使视频不再公开,URL也会返回200。例如这两个:
https://www.youtube.com/embed/kIboBC_-FRE
https://www.youtube.com/embed/kFenGaDfuI4
第一个已经成为私有的,第二个仍然可用。但他们都返回了200分。
有谁知道一种方法可以批量检查YouTube视频的可用性?
谢谢!
发布于 2019-12-05 15:05:14
第一个
第二个仍然可用:https://www.youtube.com/embed/kFenGaDfuI4
它们都返回200 (OK状态)。如何批量查看YouTube视频的可用性...对于现在是私有的视频,是否已删除,或者not available?
你也可以尝试通过Youtube的OEmbed method查看视频状态
要解决您的问题,只需使用如下所示的URL格式执行HTTP请求:
https://www.youtube.com/oembed?url=YOUR_FULL_YOUTUBE_PATH_HERE
示例:
https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=kIboBC_-FRE.因为上面是私有,所以它返回文本"Unauthorized“。
https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=R5mpcDWpYSA.因为上面是删除的,所以它返回文本"Not Found“。
https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=kFenGaDfuI4.因为上面的代码是可用的,所以会返回一些文本"{...etc...“。这也给了你其他细节,如缩略图网址,上传者的姓名和视频标题等。如果这在某种程度上有用的话。
JSON条目包括:(可以用myString.replace("\/", "//");修复)...
{
"title":"Kinetic Road Machine",
"thumbnail_url":"https:\/\/i.ytimg.com\/vi\/kFenGaDfuI4\/hqdefault.jpg",
"author_url":"https:\/\/www.youtube.com\/user\/KineticbyKurt",
"author_name":"Kinetic by Kurt"
.... etc
}发布于 2019-12-04 01:09:31
一个简单的方法是使用youtube-dl应用程序。
如果您在私有视频上运行它,如下所示:
$ youtube-dl -F https://www.youtube.com/embed/kIboBC_-FRE
[youtube] kIboBC_-FRE: Downloading webpage
[youtube] kIboBC_-FRE: Downloading embed webpage
[youtube] kIboBC_-FRE: Refetching age-gated info webpage
WARNING: Unable to extract video title
WARNING: unable to extract description; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type youtube-dl -U to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
ERROR: Content Warning
If the owner of this video has granted you access, please sign in.
This video is private.它将返回1,您可以用echo $?检查它。
非私有视频将返回0(并打印可用格式列表)。
因此,只需编写一个简单的脚本,逐行读取URL,并检查youtube-dl -F <url>是否返回0。很简单的东西。
玩得开心。
https://stackoverflow.com/questions/59160955
复制相似问题