1
0
Fork 0
mirror of synced 2024-05-20 12:12:40 +12:00

Revert "Edge case coverage"

This reverts commit 2f2b5b749c.
This commit is contained in:
SoulSuck24 2022-09-18 14:30:43 -04:00
parent 2f2b5b749c
commit d4f7deaa68
3 changed files with 8 additions and 7 deletions

View file

@ -25,7 +25,7 @@ class DownloadFactory:
@staticmethod
def pull_lever(url: str) -> Type[BaseDownloader]:
sanitised_url = DownloadFactory.sanitise_url(url)
if re.match(r'imgur\.com', sanitised_url):
if re.match(r'(i\.)?imgur.*\.gif.+$', sanitised_url):
return Imgur
elif re.match(r'(i\.)?(redgifs|gifdeliverynetwork)', sanitised_url):
return Redgifs
@ -40,6 +40,8 @@ class DownloadFactory:
return Gallery
elif re.match(r'gfycat\.', sanitised_url):
return Gfycat
elif re.match(r'(m\.)?imgur.*', sanitised_url):
return Imgur
elif re.match(r'reddit\.com/r/', sanitised_url):
return SelfPost
elif re.match(r'(m\.)?youtu\.?be', sanitised_url):

View file

@ -41,11 +41,10 @@ class Imgur(BaseDownloader):
@staticmethod
def _get_data(link: str) -> dict:
try:
imgur_id = re.match(r'.*/(.*?)(\..{0,})?$', link).group(1)
link = f'https://imgur.com/a/{imgur_id}'
except AttributeError:
raise SiteDownloaderError(f'Could not extract Imgur ID from {link}')
link = link.rstrip('?')
if re.match(r'(?i).*\.gif.+$', link):
link = link.replace('i.imgur', 'imgur')
link = re.sub('(?i)\\.gif.+$', '', link)
res = Imgur.retrieve_url(link, cookies={'over18': '1', 'postpagebeta': '0'})

View file

@ -24,7 +24,7 @@ class Redgifs(BaseDownloader):
@staticmethod
def _get_link(url: str) -> set[str]:
try:
redgif_id = re.match(r'.*/(.*?)(\..{0,})?$', url).group(1)
redgif_id = re.match(r'.*/(.*?)(\..{3,})?$', url).group(1)
except AttributeError:
raise SiteDownloaderError(f'Could not extract Redgifs ID from {url}')