[patreon] fix KeyError (#5048)
This commit is contained in:
@@ -56,15 +56,16 @@ class PatreonExtractor(Extractor):
|
|||||||
else:
|
else:
|
||||||
self.log.debug("skipping %s (%s %s)", url, fhash, kind)
|
self.log.debug("skipping %s (%s %s)", url, fhash, kind)
|
||||||
|
|
||||||
@staticmethod
|
def _postfile(self, post):
|
||||||
def _postfile(post):
|
|
||||||
postfile = post.get("post_file")
|
postfile = post.get("post_file")
|
||||||
if postfile:
|
if postfile:
|
||||||
return (("postfile", postfile["url"], postfile["name"]),)
|
url = postfile["url"]
|
||||||
|
name = postfile.get("name") or self._filename(url) or url
|
||||||
|
return (("postfile", url, name),)
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
def _images(self, post):
|
def _images(self, post):
|
||||||
for image in post["images"]:
|
for image in post.get("images") or ():
|
||||||
url = image.get("download_url")
|
url = image.get("download_url")
|
||||||
if url:
|
if url:
|
||||||
name = image.get("file_name") or self._filename(url) or url
|
name = image.get("file_name") or self._filename(url) or url
|
||||||
@@ -80,7 +81,7 @@ class PatreonExtractor(Extractor):
|
|||||||
return ()
|
return ()
|
||||||
|
|
||||||
def _attachments(self, post):
|
def _attachments(self, post):
|
||||||
for attachment in post["attachments"]:
|
for attachment in post.get("attachments") or ():
|
||||||
url = self.request(
|
url = self.request(
|
||||||
attachment["url"], method="HEAD",
|
attachment["url"], method="HEAD",
|
||||||
allow_redirects=False, fatal=False,
|
allow_redirects=False, fatal=False,
|
||||||
|
|||||||
Reference in New Issue
Block a user