【问题标题】:Check YouTube URLs in bulk批量检查 YouTube 网址
【发布时间】:2020-07-21 22:33:27
【问题描述】:

我们正在寻找一种方法来检查一长串 YouTube 网址,以查找现在不公开、已被删除或不再可用的视频。我们可以检查状态,但即使视频不再公开,URL 也会返回 200。比如这两个:

https://www.youtube.com/embed/kIboBC_-FRE

https://www.youtube.com/embed/kFenGaDfuI4

第一个已设为私有,第二个仍然可用。但他们都返回 200s。

有人知道批量检查 YouTube 视频可用性的方法吗?

谢谢!

【问题讨论】:

  • 这个列表是真实的 Youtube 播放列表吗?
  • 没有。只是我们托管的各种网站上嵌入视频的 URL 列表。我们需要能够清理旧的死嵌入视频。

标签: video youtube status


【解决方案1】:

第一个已设为私有: https://www.youtube.com/embed/kIboBC_-FRE

第二个仍然可用: https://www.youtube.com/embed/kFenGaDfuI4

它们都返回 200(OK 状态)。如何检查 YouTube 视频的可用性 批量...对于现在私有、已删除的视频,或 否则不可用了吗?

您也可以尝试通过 Youtube 的OEmbed method查看视频状态:

要解决您的问题,只需使用如下所示的 URL 格式发出 HTTP 请求:

https://www.youtube.com/oembed?url=YOUR_FULL_YOUTUBE_PATH_HERE

例子:

  1. https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=kIboBC_-FRE

    因为上面是private,所以返回文本“Unauthorized”。

  1. https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=R5mpcDWpYSA

    由于上述内容已删除,因此返回文本“Not Found”。

  1. https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=kFenGaDfuI4.

    因为上面是 availabe 这会返回一些 JSON 文本“{...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
}

【讨论】:

  • 哇,这太完美了。谢谢!
【解决方案2】:

一个简单的方法是使用youtube-dl app。

如果你在私人视频上运行它:

$ 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。简单的东西。

玩得开心。

【讨论】:

    猜你喜欢
    • 2012-07-18
    • 2012-02-07
    • 2013-09-07
    • 2018-04-24
    • 2017-08-10
    • 1970-01-01
    • 2011-03-03
    • 2018-03-09
    • 1970-01-01
    相关资源
    最近更新 更多