Skip to content

Commit

Permalink
[kemonoparty] Duplicate file fix
Browse files Browse the repository at this point in the history
Fixes mikf#1667 

Judging by the discussion in that thread, the first file is always duplicated in the attachments list, except for some posts which only have the image and no attachments.

This change makes it so if attachments are present it only downloads those.

It might require testing from various posts though. It worked in the one I tried for what it's worth, but I'm not too familiar with the service.
  • Loading branch information
nixxquality authored Jul 13, 2021
1 parent 193401c commit bf532df
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gallery_dl/extractor/kemonoparty.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,20 @@ def items(self):
files = []
append = files.append
file = post["file"]
got_attachment = False

if file:
file["type"] = "file"
append(file)
for attachment in post["attachments"]:
attachment["type"] = "attachment"
got_attachment = True
append(attachment)
for path in find_inline(post["content"] or ""):
append({"path": path, "name": path, "type": "inline"})

if got_attachment:
files = files[1:] # ignore the first file if there are attachments

post["date"] = text.parse_datetime(
post["published"], "%a, %d %b %Y %H:%M:%S %Z")
Expand Down

0 comments on commit bf532df

Please sign in to comment.