Catch some Imgur errors with weird links
This commit is contained in:
parent
b632fd089b
commit
e8998da2f0
|
@ -37,9 +37,10 @@ class Imgur(BaseDownloader):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _get_data(link: str) -> dict:
|
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 = 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'})
|
res = Imgur.retrieve_url(link, cookies={'over18': '1', 'postpagebeta': '0'})
|
||||||
|
|
||||||
|
|
|
@ -132,10 +132,16 @@ def test_imgur_extension_validation_bad(test_extension: str):
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
'https://i.imgur.com/lFJai6i.gifv',
|
'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]):
|
def test_find_resources(test_url: str, expected_hashes: list[str]):
|
||||||
mock_download = Mock()
|
mock_download = Mock()
|
||||||
|
|
Loading…
Reference in a new issue