1

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.

Davit Tovmasyan
  • 2,810
  • 2
  • 19
  • 33
  • Does this answer your question? [Validating URLs in Python](https://stackoverflow.com/questions/22238090/validating-urls-in-python) – Davit Tovmasyan Apr 27 '20 at 18:52

1 Answers1

3

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

m8factorial
  • 178
  • 6
  • I update my code above. You need to execute this in a python file. Search about how do it. There's lots of tutorials. Ex: https://realpython.com/run-python-scripts/ Good luck! – m8factorial Apr 29 '20 at 07:45
  • As far as I understand I can pass custom list of extactors to limit services? https://stackoverflow.com/q/62203971/7415288 – Marat Mkhitaryan Jun 04 '20 at 21:14