parent
2f2b5b749c
commit
d4f7deaa68
@ -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):
|
||||
|
@ -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'})
|
||||
|
||||
|
@ -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}')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user