1
0
Fork 0
mirror of synced 2024-05-28 16:09:55 +12:00

Redgifs fix

Handle redgifs link with trailing / causing id to return empty string.
This commit is contained in:
Soulsuck24 2022-12-19 11:02:06 -05:00
parent 7cf096012e
commit 603e7de04d
No known key found for this signature in database
GPG key ID: EDBD4E9B4DA565B4
2 changed files with 3 additions and 0 deletions

View file

@ -24,6 +24,8 @@ class Redgifs(BaseDownloader):
@staticmethod
def _get_link(url: str) -> set[str]:
try:
if url.endswith("/"):
url = url.removesuffix("/")
redgif_id = re.match(r".*/(.*?)(\..{0,})?$", url).group(1)
except AttributeError:
raise SiteDownloaderError(f"Could not extract Redgifs ID from {url}")

View file

@ -29,6 +29,7 @@ from bdfr.site_downloaders.redgifs import Redgifs
"UnripeUnkemptWoodpecker-large.jpg",
},
),
("https://www.redgifs.com/watch/genuineprivateguillemot/", {"GenuinePrivateGuillemot.mp4"}),
),
)
def test_get_link(test_url: str, expected: set[str]):