1
0
Fork 0
mirror of synced 2024-05-19 19:52:41 +12:00

Redgif updates

Coverage for direct links.

The direct link won't work because it will have the wrong auth anyway but this will at least end up with the right API call.
This commit is contained in:
Soulsuck24 2022-12-26 20:25:20 -05:00
parent 7cd1a70f59
commit 13887ca7e1
No known key found for this signature in database
GPG key ID: EDBD4E9B4DA565B4
2 changed files with 5 additions and 1 deletions

View file

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

View file

@ -16,6 +16,8 @@ from bdfr.site_downloaders.redgifs import Redgifs
("https://redgifs.com/watch/frighteningvictorioussalamander", "frighteningvictorioussalamander"),
("https://www.redgifs.com/watch/genuineprivateguillemot/", "genuineprivateguillemot"),
("https://www.redgifs.com/watch/marriedcrushingcob?rel=u%3Akokiri.girl%3Bo%3Arecent", "marriedcrushingcob"),
("https://thumbs4.redgifs.com/DismalIgnorantDrongo.mp4", "dismalignorantdrongo"),
("https://thumbs4.redgifs.com/DismalIgnorantDrongo-mobile.mp4", "dismalignorantdrongo"),
),
)
def test_get_id(test_url: str, expected: str):