【问题标题】:How to check if a url is valid that youtube-dl supports如何检查 youtube-dl 支持的 url 是否有效
【发布时间】:2020-04-27 18:02:40
【问题描述】:

我正在开发一个项目,用户在其中提交一个 URL。 我需要检查该 URL 是否为有效 url ,以便从 youtube-dl 支持的站点下载数据。

请帮忙。

【问题讨论】:

标签: python youtube-dl


【解决方案1】:

试试这个功能:

import youtube-dl

url = 'type your url here'

def is_supported(url):
    extractors = youtube_dl.extractor.gen_extractors()
    for e in extractors:
        if e.suitable(url) and e.IE_NAME != 'generic':
            return True
    return False

print (is_supported(url))

记住:你需要导入 youtube_dl

【讨论】:

猜你喜欢
  • 2014-07-24
  • 2021-08-06
  • 1970-01-01
  • 2020-11-29
  • 2010-12-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-17
相关资源
最近更新 更多