From e4b4e456ca9188d305c1af443a4c947bae570646 Mon Sep 17 00:00:00 2001 From: Rahman Yusuf Date: Mon, 26 Jun 2023 22:12:19 +0700 Subject: [PATCH] Fix formats `pdf-volume` and `cb7-volume` are not working --- docs/changelog.md | 7 +++++++ mangadex_downloader/format/base.py | 6 +++--- mangadex_downloader/format/comic_book.py | 2 +- mangadex_downloader/format/epub.py | 2 +- mangadex_downloader/format/pdf.py | 5 ++++- mangadex_downloader/format/sevenzip.py | 4 +++- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index ed9d4387..0e2bef28 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,5 +1,12 @@ # Changelog +## UNRELEASED + +### Fix bugs + +- Fixed `pdf-volume` and `cb7-volume` formats are not working after upgrading to v2.10.0 +[#78](https://github.com/mansuf/mangadex-downloader/issues/78) + ## v2.10.1 ### Fix bugs diff --git a/mangadex_downloader/format/base.py b/mangadex_downloader/format/base.py index 46b42798..e3c51580 100644 --- a/mangadex_downloader/format/base.py +++ b/mangadex_downloader/format/base.py @@ -574,8 +574,8 @@ def on_received_images(self, file_path, chapter, images): """This function is called when format has successfully received images""" pass - def on_finish(self, file_path, volume, images): - """"This function is called after download is finished""" + def on_convert(self, file_path, volume, images): + """"This function is called when convert process is starting""" pass def download_volumes(self, volumes): @@ -622,7 +622,7 @@ def download_volumes(self, volumes): pbm.get_pages_pb().reset() chapters_pb.reset() - self.on_finish(file_path, volume, images) + self.on_convert(file_path, volume, images) # Remove original chapter folder shutil.rmtree(volume_path, ignore_errors=True) diff --git a/mangadex_downloader/format/comic_book.py b/mangadex_downloader/format/comic_book.py index 97a0d146..e5976991 100644 --- a/mangadex_downloader/format/comic_book.py +++ b/mangadex_downloader/format/comic_book.py @@ -195,7 +195,7 @@ def on_prepare(self, file_path, volume, count): def on_iter_chapter(self, file_path, chapter, count): self.insert_ch_info_img(self.volume_zip, self.worker, chapter, count, self.volume_path) - def on_finish(self, file_path, volume, images): + def on_convert(self, file_path, volume, images): volume_name = self.get_volume_name(volume) pbm.logger.info(f"{volume_name} has finished download, converting to cbz...") diff --git a/mangadex_downloader/format/epub.py b/mangadex_downloader/format/epub.py index d88e3088..f86b41bb 100644 --- a/mangadex_downloader/format/epub.py +++ b/mangadex_downloader/format/epub.py @@ -435,7 +435,7 @@ class EpubVolume(ConvertedVolumesFormat, EPUBFile): def on_prepare(self, file_path, volume, count): self.epub_chapters = [] - def on_finish(self, file_path, volume, images): + def on_convert(self, file_path, volume, images): volume_name = self.get_volume_name(volume) pbm.logger.info(f"{volume_name} has finished download, converting to epub...") diff --git a/mangadex_downloader/format/pdf.py b/mangadex_downloader/format/pdf.py index 46c65598..d99a1ef3 100644 --- a/mangadex_downloader/format/pdf.py +++ b/mangadex_downloader/format/pdf.py @@ -440,6 +440,9 @@ def __init__(self, *args, **kwargs): self.images = [] def on_prepare(self, file_path, volume, count): + # We should clear self.images, to prevent older volumes to be re-converted + self.images.clear() + volume_name = self.get_volume_name(volume) self.volume_path = create_directory(volume_name, self.path) @@ -448,7 +451,7 @@ def on_prepare(self, file_path, volume, count): def on_iter_chapter(self, file_path, chapter, count): self.insert_ch_info_img(self.images, chapter, self.volume_path, count) - def on_finish(self, file_path, volume, images): + def on_convert(self, file_path, volume, images): volume_name = self.get_volume_name(volume) pbm.logger.info(f"{volume_name} has finished download, converting to pdf...") self.worker.submit(lambda: self.convert(self.images, file_path)) diff --git a/mangadex_downloader/format/sevenzip.py b/mangadex_downloader/format/sevenzip.py index 43a38b67..37bb26d1 100644 --- a/mangadex_downloader/format/sevenzip.py +++ b/mangadex_downloader/format/sevenzip.py @@ -112,6 +112,8 @@ def __init__(self, *args, **kwargs): self.images = [] def on_prepare(self, file_path, volume, count): + self.images.clear() + volume_name = self.get_volume_name(volume) self.volume_path = create_directory(volume_name, self.path) @@ -123,7 +125,7 @@ def on_iter_chapter(self, file_path, chapter, count): def on_received_images(self, file_path, chapter, images): self.images.extend(images) - def on_finish(self, file_path, volume, images): + def on_convert(self, file_path, volume, images): volume_name = self.get_volume_name(volume) pbm.logger.info(f"{volume_name} has finished download, converting to cb7...")