Catch some Imgur errors with weird links

This commit is contained in:
Serene-Arc
2021-06-24 20:10:31 +10:00
parent b632fd089b
commit e8998da2f0
2 changed files with 13 additions and 6 deletions

View File

@@ -37,9 +37,10 @@ class Imgur(BaseDownloader):
@staticmethod
def _get_data(link: str) -> dict:
if re.match(r'.*\.gifv$', link):
link = link.rstrip('?')
if re.match(r'(?i).*\.gifv$', link):
link = link.replace('i.imgur', 'imgur')
link = re.sub('\\.gifv$', '', link)
link = re.sub('(?i)\\.gifv$', '', link)
res = Imgur.retrieve_url(link, cookies={'over18': '1', 'postpagebeta': '0'})