Skip to content

Commit

Permalink
[koharu] fix 'count' for 'cbz' downloads (#5893)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Aug 2, 2024
1 parent d65fc24 commit 9be7896
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions gallery_dl/extractor/koharu.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class KoharuGalleryExtractor(KoharuExtractor, GalleryExtractor):
filename_fmt = "{num:>03}.{extension}"
directory_fmt = ("{category}", "{id} {title}")
archive_fmt = "{id}_{num}"
request_interval = 0.0
pattern = BASE_PATTERN + r"/(?:g|reader)/(\d+)/(\w+)"
example = "https://koharu.to/g/12345/67890abcde/"

Expand Down Expand Up @@ -101,8 +102,6 @@ def metadata(self, _):
url = "{}/books/detail/{}/{}".format(
self.root_api, self.groups[0], self.groups[1])
self.data = data = self.request(url, headers=self.headers).json()
data.pop("rels", None)
data.pop("thumbnails", None)

tags = []
for tag in data["tags"]:
Expand All @@ -112,6 +111,14 @@ def metadata(self, _):
data["tags"] = tags
data["date"] = text.parse_timestamp(data["created_at"] // 1000)

try:
if self.cbz:
data["count"] = len(data["thumbnails"]["entries"])
del data["thumbnails"]
del data["rels"]
except Exception:
pass

return data

def images(self, _):
Expand Down
2 changes: 1 addition & 1 deletion test/results/koharu.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"#pattern" : r"https://kisakisexo.xyz/download/59896/a4fbd1828229/f47639c6abaf1903dd69c36a3d961da84741a1831aa07a2906ce9c74156a5d75\?v=1721626410802&w=0",
"#count" : 1,

"count" : 1,
"count" : 22,
"created_at": 1721626410802,
"date" : "dt:2024-07-22 05:33:30",
"extension" : "cbz",
Expand Down

0 comments on commit 9be7896

Please sign in to comment.