download_factory.py: check if url has ext first

This commit is contained in:
Ali Parlakci 2021-04-03 19:44:53 +03:00
parent 4e35f0db2b
commit ab29e17511

View File

@ -22,7 +22,11 @@ class DownloadFactory:
@staticmethod
def pull_lever(url: str) -> Type[BaseDownloader]:
url_beginning = r'\s*(https?://(www\.)?)'
if re.match(url_beginning + r'erome\.com.*', url):
if re.match(url_beginning + r'i\.imgur.*\.gifv$', url):
return Imgur
elif re.match(url_beginning + r'.*/.*\.\w{3,4}$', url):
return Direct
elif re.match(url_beginning + r'erome\.com.*', url):
return Erome
elif re.match(url_beginning + r'reddit\.com/gallery/.*', url):
return Gallery
@ -32,8 +36,6 @@ class DownloadFactory:
return GifDeliveryNetwork
elif re.match(url_beginning + r'imgur.*', url):
return Imgur
elif re.match(url_beginning + r'i\.imgur.*\.gifv$', url):
return Imgur
elif re.match(url_beginning + r'redgifs.com', url):
return Redgifs
elif re.match(url_beginning + r'reddit\.com/r/', url):
@ -44,7 +46,5 @@ class DownloadFactory:
return Youtube
elif re.match(url_beginning + r'i\.redd\.it.*', url):
return Direct
elif re.match(url_beginning + r'.*/.*\.\w{3,4}$', url):
return Direct
else:
raise NotADownloadableLinkError(f'No downloader module exists for url {url}')