Q:

How to check if a url is valid that youtube-dl supports

I am developing a project, where user submits a URL.
I need to check if that URL is valid url , to download data from youtube-dl supported sites.
Please help.

A:

Try this function:
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))

Remember: you need to import youtube_dl

