From 13887ca7e1acd605426537a6043bf901aee55515 Mon Sep 17 00:00:00 2001 From: Soulsuck24 <79275800+Soulsuck24@users.noreply.github.com> Date: Mon, 26 Dec 2022 20:25:20 -0500 Subject: [PATCH] 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. --- bdfr/site_downloaders/redgifs.py | 4 +++- tests/site_downloaders/test_redgifs.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/bdfr/site_downloaders/redgifs.py b/bdfr/site_downloaders/redgifs.py index 95d23d2..205674a 100644 --- a/bdfr/site_downloaders/redgifs.py +++ b/bdfr/site_downloaders/redgifs.py @@ -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 diff --git a/tests/site_downloaders/test_redgifs.py b/tests/site_downloaders/test_redgifs.py index fd0e0ed..5f4f6fc 100644 --- a/tests/site_downloaders/test_redgifs.py +++ b/tests/site_downloaders/test_redgifs.py @@ -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):