1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 18:53:21 +01:00

[redgifs] improve URL extraction

Fields inside 'urls' can be None, which would have caused an exception
with the old method.
This commit is contained in:
Mike Fährmann 2021-11-05 20:02:43 +01:00
parent 2befed1a96
commit 7cb303d745
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -21,7 +21,7 @@ class RedgifsExtractor(Extractor):
def __init__(self, match):
Extractor.__init__(self, match)
self.key = match.group(1).lower()
self.key = match.group(1)
formats = self.config("format")
if formats is None:
@ -51,8 +51,8 @@ class RedgifsExtractor(Extractor):
def _formats(self, gif):
urls = gif["urls"]
for fmt in self.formats:
if fmt in urls:
url = urls[fmt]
url = urls.get(fmt)
if url:
text.nameext_from_url(url, gif)
yield url
@ -129,7 +129,7 @@ class RedgifsAPI():
self.extractor = extractor
def gif(self, gif_id):
endpoint = "/v2/gifs/" + gif_id
endpoint = "/v2/gifs/" + gif_id.lower()
return self._call(endpoint)["gif"]
def user(self, user, order="best"):