1
0
Fork 0
mirror of synced 2024-10-01 09:41:03 +13:00

Imgur fixes

Update regex for links styled as direct and album
This commit is contained in:
Soulsuck24 2023-02-27 15:53:47 -05:00
parent 6df7906818
commit dd283130e3
No known key found for this signature in database
GPG key ID: EDBD4E9B4DA565B4
2 changed files with 2 additions and 1 deletions

View file

@ -40,7 +40,7 @@ class Imgur(BaseDownloader):
if link.endswith("/"):
link = link.removesuffix("/")
if re.search(r".*/(.*?)(gallery/|a/)", link):
imgur_id = re.match(r".*/(?:gallery/|a/)(.*?)(?:/.*)?$", link).group(1)
imgur_id = re.match(r".*/(?:gallery/|a/)(.*?)(?:/.*|\..{3,4})?$", link).group(1)
link = f"https://api.imgur.com/3/album/{imgur_id}"
else:
imgur_id = re.match(r".*/(.*?)(?:_d)?(?:\..{0,})?$", link).group(1)

View file

@ -49,6 +49,7 @@ from bdfr.site_downloaders.imgur import Imgur
("https://imgur.com/a/1qzfWtY/mp4", ("65fbc7ba5c3ed0e3af47c4feef4d3735",)),
("https://imgur.com/a/1qzfWtY/spqr", ("65fbc7ba5c3ed0e3af47c4feef4d3735",)),
("https://i.imgur.com/expO7Rc.gifv", ("e309f98158fc98072eb2ae68f947f421",)),
("https://i.imgur.com/a/aqpiMuL.gif", ("5b2a9a5218bf43dc26ba41389410c981",)),
),
)
def test_find_resources(test_url: str, expected_hashes: list[str]):