1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-23 03:02:50 +01:00

[patreon] fix KeyError (#5048)

This commit is contained in:
Mike Fährmann 2024-01-11 17:56:47 +01:00
parent 2191e29e14
commit 1c68b7df01
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -56,15 +56,16 @@ class PatreonExtractor(Extractor):
else:
self.log.debug("skipping %s (%s %s)", url, fhash, kind)
@staticmethod
def _postfile(post):
def _postfile(self, post):
postfile = post.get("post_file")
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 ()
def _images(self, post):
for image in post["images"]:
for image in post.get("images") or ():
url = image.get("download_url")
if url:
name = image.get("file_name") or self._filename(url) or url
@ -80,7 +81,7 @@ class PatreonExtractor(Extractor):
return ()
def _attachments(self, post):
for attachment in post["attachments"]:
for attachment in post.get("attachments") or ():
url = self.request(
attachment["url"], method="HEAD",
allow_redirects=False, fatal=False,