Skip to content

Commit

Permalink
[kemonoparty] fix deleting 'name' in orginal objects (mikf#5103)
Browse files Browse the repository at this point in the history
... when computing 'revision_hash'

regression caused by 3d68eda

dict.copy() only creates a shallow copy
I know that and still managed to get I wrong ...
  • Loading branch information
mikf authored and bradenhilton committed Feb 5, 2024
1 parent 380f48c commit fcf8750
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions gallery_dl/extractor/kemonoparty.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ def _revision_hash(self, revision):
rev.pop("added", None)
rev.pop("next", None)
rev.pop("prev", None)
rev["file"] = rev["file"].copy()
rev["file"].pop("name", None)
rev["attachments"] = [a.copy() for a in rev["attachments"]]
for a in rev["attachments"]:
a.pop("name", None)
return util.sha1(self._json_dumps(rev))
Expand Down
23 changes: 20 additions & 3 deletions test/results/kemonoparty.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,26 @@
"#class" : kemonoparty.KemonopartyPostExtractor,
"#urls" : "https://kemono.su/data/88/52/88521f71822dfa2f42df3beba319ea4fceda2a2d6dc59da0276a75238f743f86.jpg",

"revision_id": 142470,
"file" : {
"hash": "88521f71822dfa2f42df3beba319ea4fceda2a2d6dc59da0276a75238f743f86",
"name": "wip update.jpg",
"path": "/88/52/88521f71822dfa2f42df3beba319ea4fceda2a2d6dc59da0276a75238f743f86.jpg",
"type": "file",
},
"attachments": [
{
"hash": "88521f71822dfa2f42df3beba319ea4fceda2a2d6dc59da0276a75238f743f86",
"name": "wip update.jpg",
"path": "/88/52/88521f71822dfa2f42df3beba319ea4fceda2a2d6dc59da0276a75238f743f86.jpg",
"type": "attachment",
},
],
"filename" : "wip update",
"extension" : "jpg",
"hash" : "88521f71822dfa2f42df3beba319ea4fceda2a2d6dc59da0276a75238f743f86",
"revision_id" : 142470,
"revision_index": 2,
"revision_hash": "e0e93281495e151b11636c156e52bfe9234c2a40",
"revision_hash" : "e0e93281495e151b11636c156e52bfe9234c2a40",
},

{
Expand All @@ -191,7 +208,7 @@

"revision_id": range(134996, 3052965),
"revision_index": range(1, 9),
"revision_hash": r"re:^[0-9a-f]{40}$",
"revision_hash": "e0e93281495e151b11636c156e52bfe9234c2a40",
},


Expand Down

0 comments on commit fcf8750

Please sign in to comment.