1
0
Fork 0
mirror of synced 2024-09-29 16:51:30 +13:00

Merge pull request #847 from Soulsuck24/development

This commit is contained in:
Serene 2023-04-30 11:33:37 +10:00 committed by GitHub
commit 17350ba9b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 3 deletions

View file

@ -27,7 +27,7 @@ class DownloadFactory:
sanitised_url = DownloadFactory.sanitise_url(url).lower()
if re.match(r"(i\.|m\.|o\.)?imgur", sanitised_url):
return Imgur
elif re.match(r"(i\.|thumbs\d\.|v\d\.)?(redgifs|gifdeliverynetwork)", sanitised_url):
elif re.match(r"(i\.|thumbs\d{1,2}\.|v\d\.)?(redgifs|gifdeliverynetwork)", sanitised_url):
return Redgifs
elif re.match(r"(thumbs\.|giant\.)?gfycat\.", sanitised_url):
return Gfycat

View file

@ -33,8 +33,7 @@ class Redgifs(BaseDownloader):
if url.endswith("/"):
url = url.removesuffix("/")
redgif_id = re.match(r".*/(.*?)(?:#.*|\?.*|\..{0,})?$", url).group(1).lower()
if redgif_id.endswith("-mobile"):
redgif_id = redgif_id.removesuffix("-mobile")
redgif_id = re.sub(r"(-.*)$", "", redgif_id)
except AttributeError:
raise SiteDownloaderError(f"Could not extract Redgifs ID from {url}")
return redgif_id

View file

@ -25,6 +25,7 @@ def test_auth_cache():
("https://thumbs4.redgifs.com/DismalIgnorantDrongo.mp4", "dismalignorantdrongo"),
("https://thumbs4.redgifs.com/DismalIgnorantDrongo-mobile.mp4", "dismalignorantdrongo"),
("https://v3.redgifs.com/watch/newilliteratemeerkat#rel=user%3Atastynova", "newilliteratemeerkat"),
("https://thumbs46.redgifs.com/BabyishCharmingAidi-medium.jpg", "babyishcharmingaidi"),
),
)
def test_get_id(test_url: str, expected: str):
@ -81,6 +82,7 @@ def test_get_link(test_url: str, expected: set[str]):
"44fb28f72ec9a5cca63fa4369ab4f672",
},
),
("https://thumbs46.redgifs.com/BabyishCharmingAidi-medium.jpg", {"bf14b9f3d5b630cb5fd271661226f1af"}),
),
)
def test_download_resource(test_url: str, expected_hashes: set[str]):