Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
How can i check if the url is a valid url before downloading ? #11649
Comments
|
Use |
|
Where would i have to use ? completely lost |
|
Are you writing extractors or just using youtube-dl as a CLI program? |
|
Writing an extractor
|
|
Well, at this level _is_valid_url is not available. Need other approaches. What's your scenario? |
|
I want to add a feature to my website to let persons download songs but if the person entered an invalid url i want to run some functions |
|
I guess I've got you. Just catch |
|
How to do this ? Can you give me a short example please |
|
Like this. Do whatever you want to from youtube_dl.utils import ExtractorError
try:
info_dict = ydl.extract_info(url, download=False)
except ExtractorError as e:
print(e) |
|
thanks. if you dont mind can you hit me up a quick email deangeloalmeus@gmail.com |
|
How about using Regular Expressions to check? Pretty much the standard way to validate form input. |
|
I was thinking the same thing but i want to send the users to an error page if their is an error in the url. |
|
Oops I forgot DownloadError wraps ExtractorError. Replace ExtractorError in the previous code with DownloadError |
|
Dont worry i got it to work thanks guys :) |


How can i check if the url is a valid url before downloading ?