Closed deangelo200 closed 7 years ago
Use self._is_valid_url()
Where would i have to use ? completely lost
Are you writing extractors or just using youtube-dl as a CLI program?
Writing an extractor ` with youtube_dl.YoutubeDL(ydl_opts) as ydl: info_dict = ydl.extract_info(url, download=False) video_id = info_dict.get("id", None) video_title = info_dict.get('title', None) video_thumb = info_dict.get('thumbnail',None) context = { 'form': form, 'title':video_title, 'id': video_id, 'thumbnails':video_thumb
}`
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 ExtractorError
and analyze it
How to do this ? Can you give me a short example please
Like this. Do whatever you want to e
.
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
Hey am getting this error instead of getting this error i want to send the user to a page
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
Are you familiar with Django
Dont worry i got it to work thanks guys :)
How can i check if the url is a valid url before downloading ?