athrowaway2021 / comix

Seamlessly download and de-drm comics and manga from Kindle in highest possible quality
MIT License
61 stars 20 forks source link

Error with some manga - RuntimeError: Bad password #2

Closed Neogrey closed 3 years ago

Neogrey commented 3 years ago

Comix works with most titles however there seems to be problems with manga published by Kodansha?. Both "Hozuki's Coolheadedness" and "Kino's Journey" cannot be saved.

# python3 comix.py 871492
871492 : Kino's Journey - v06
Downloading page 000 . . .Traceback (most recent call last):
  File "/home/user/Downloads/comix-main/comix.py", line 138, in <module>
    cmx.download()
  File "/home/user/Downloads/comix-main/comix.py", line 114, in download
    zf.extractall(content_folder, pwd=image_key)
  File "/usr/local/lib/python3.9/dist-packages/pyzipper/zipfile.py", line 2106, in extractall
    self._extract_member(zipinfo, path, pwd)
  File "/usr/local/lib/python3.9/dist-packages/pyzipper/zipfile.py", line 2159, in _extract_member
    with self.open(member, pwd=pwd) as source, \
  File "/usr/local/lib/python3.9/dist-packages/pyzipper/zipfile.py", line 2013, in open
    return self._open_to_read(mode, zinfo, pwd)
  File "/usr/local/lib/python3.9/dist-packages/pyzipper/zipfile.py", line 2024, in _open_to_read
    raise e
  File "/usr/local/lib/python3.9/dist-packages/pyzipper/zipfile.py", line 2021, in _open_to_read
    return self.zipextfile_cls(zef_file, mode, zinfo, True, pwd)
  File "/usr/local/lib/python3.9/dist-packages/pyzipper/zipfile.py", line 1203, in __init__
    self.read_init()
  File "/usr/local/lib/python3.9/dist-packages/pyzipper/zipfile.py", line 1218, in read_init
    self._decrypter = self.get_decrypter()
  File "/usr/local/lib/python3.9/dist-packages/pyzipper/zipfile.py", line 1306, in get_decrypter
    decrypter = self._decrypter_cls(
  File "/usr/local/lib/python3.9/dist-packages/pyzipper/zipfile_aes.py", line 61, in __init__
    raise RuntimeError("Bad password for file %r" % zinfo.filename)
RuntimeError: Bad password for file 'COMIXOLOGY_BOOK_ENCRYPTED_HD_0001.jpg'

I don't have this issue with volumes from other publishers so far.

athrowaway2021 commented 3 years ago

The password derivation fails since Kodansha's imprints, Vertical and Digital-First have unique publisher IDs delivered in the protobufs but the passwords are still generated with Kodansha's publisher ID. Fixed it in f93f0d7e32b014e2e6de5530ec8ae6ddad4bc8f3 with a hack for now.

Neogrey commented 3 years ago

@athrowaway2021 thanks for the fix. But I had to replace publisher_id with self.publisher_id, then it works.

I guess it should be like this:

        if self.publisher_id == "274" or self.publisher_id == "281":
            self.publisher_id = "6670"