[gfycat] show warning when there are no available formats

This commit is contained in:
Mike Fährmann
2021-10-26 19:26:50 +02:00
parent e436a2607b
commit dcb201ff19

View File

@@ -36,7 +36,13 @@ class GfycatExtractor(Extractor):
if "gfyName" not in gfycat: if "gfyName" not in gfycat:
self.log.warning("Skipping '%s' (malformed)", gfycat["gfyId"]) self.log.warning("Skipping '%s' (malformed)", gfycat["gfyId"])
continue continue
url = self._process(gfycat) url = self._process(gfycat)
if not url:
self.log.warning("Skipping '%s' (format not available)",
gfycat["gfyId"])
continue
gfycat.update(metadata) gfycat.update(metadata)
yield Message.Directory, gfycat yield Message.Directory, gfycat
yield Message.Url, url, gfycat yield Message.Url, url, gfycat
@@ -44,7 +50,7 @@ class GfycatExtractor(Extractor):
def _process(self, gfycat): def _process(self, gfycat):
gfycat["_fallback"] = formats = self._formats(gfycat) gfycat["_fallback"] = formats = self._formats(gfycat)
gfycat["date"] = text.parse_timestamp(gfycat.get("createDate")) gfycat["date"] = text.parse_timestamp(gfycat.get("createDate"))
return next(formats, "") return next(formats, None)
def _formats(self, gfycat): def _formats(self, gfycat):
for fmt in self.formats: for fmt in self.formats:
@@ -158,6 +164,10 @@ class GfycatImageExtractor(GfycatExtractor):
self.log.warning("Skipping '%s' (malformed)", gfycat["gfyId"]) self.log.warning("Skipping '%s' (malformed)", gfycat["gfyId"])
return return
url = self._process(gfycat) url = self._process(gfycat)
if not url:
self.log.warning("Skipping '%s' (format not available)",
gfycat["gfyId"])
return
yield Message.Directory, gfycat yield Message.Directory, gfycat
yield Message.Url, url, gfycat yield Message.Url, url, gfycat