Skip to content

Commit

Permalink
[gfycat] skip malformed gfycat responses (closes #902)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jul 22, 2020
1 parent 453f3bc commit baf5d0e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions gallery_dl/extractor/gfycat.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def __init__(self, match):
def items(self):
metadata = self.metadata()
for gfycat in self.gfycats():
if "gfyName" not in gfycat:
self.log.warning("Skipping '%s' (malformed)", gfycat["gfyId"])
continue
url = self._select_format(gfycat)
gfycat.update(metadata)
yield Message.Directory, gfycat
Expand Down Expand Up @@ -118,6 +121,10 @@ class GfycatImageExtractor(GfycatExtractor):
("https://www.gfycat.com/foolishforkedabyssiniancat", {
"pattern": "https://redgifs.com/watch/foolishforkedabyssiniancat",
}),
# malformed API response (#902)
("https://gfycat.com/illexcitablehairstreak", {
"count": 0,
}),
("https://gfycat.com/gifs/detail/UnequaledHastyAnkole"),
("https://gfycat.com/ifr/UnequaledHastyAnkole"),
("https://gfycat.com/ru/UnequaledHastyAnkole"),
Expand All @@ -132,6 +139,9 @@ def items(self):
data = {"_extractor": RedgifsImageExtractor}
yield Message.Queue, url, data
else:
if "gfyName" not in gfycat:
self.log.warning("Skipping '%s' (malformed)", gfycat["gfyId"])
return
url = self._select_format(gfycat)
yield Message.Directory, gfycat
yield Message.Url, url, gfycat
Expand Down

0 comments on commit baf5d0e

Please sign in to comment.