1
0
Fork 0
mirror of synced 2024-06-20 19:20:20 +12:00

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'})

View file

@ -132,10 +132,16 @@ def test_imgur_extension_validation_bad(test_extension: str):
),
(
'https://i.imgur.com/lFJai6i.gifv',
(
'01a6e79a30bec0e644e5da12365d5071',
),
)
('01a6e79a30bec0e644e5da12365d5071',),
),
(
'https://i.imgur.com/ywSyILa.gifv?',
('56d4afc32d2966017c38d98568709b45',),
),
(
'https://imgur.com/ubYwpbk.GIFV',
('d4a774aac1667783f9ed3a1bd02fac0c',),
),
))
def test_find_resources(test_url: str, expected_hashes: list[str]):
mock_download = Mock()