[koharu] fix 'count' for 'cbz' downloads (#5893)

This commit is contained in:
Mike Fährmann
2024-08-02 09:10:48 +02:00
parent d65fc2435c
commit 9be7896f78
2 changed files with 10 additions and 3 deletions

View File

@@ -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/"
@@ -101,8 +102,6 @@ class KoharuGalleryExtractor(KoharuExtractor, GalleryExtractor):
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"]:
@@ -112,6 +111,14 @@ class KoharuGalleryExtractor(KoharuExtractor, GalleryExtractor):
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, _):