mansuf / mangadex-downloader

A command-line tool to download manga from MangaDex, written in Python.
https://mangadex-dl.mansuf.link/
MIT License
472 stars 37 forks source link

FileNotFoundError when downloading PDF volumes #78

Closed Ethaisa123 closed 1 year ago

Ethaisa123 commented 1 year ago

What happened ?

After downloading the chapters when the worker converts the volume into a PDF I get a FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\Ethan\Downloads\Kobo-pine\New Normal\Vol. 3\000.png

Full error below:

[ERROR] We have problem in queue worker
Traceback (most recent call last):
  File "C:\Users\Ethan\AppData\Local\Programs\Python\Python311\Lib\site-packages\mangadex_downloader\utils.py", line 217, in run
    job()
  File "C:\Users\Ethan\AppData\Local\Programs\Python\Python311\Lib\site-packages\mangadex_downloader\format\pdf.py", line 454, in <lambda>
    self.worker.submit(lambda: self.convert(self.images, file_path))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ethan\AppData\Local\Programs\Python\Python311\Lib\site-packages\mangadex_downloader\format\pdf.py", line 392, in convert
    im = im_ref()
         ^^^^^^^^
  File "C:\Users\Ethan\AppData\Local\Programs\Python\Python311\Lib\site-packages\mangadex_downloader\format\pdf.py", line 68, in __call__
    return self._func(*self._args, **self._kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ethan\AppData\Local\Programs\Python\Python311\Lib\site-packages\PIL\Image.py", line 3236, in open
    fp = builtins.open(filename, "rb")
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Ethan\\Downloads\\Kobo-pine\\New Normal\\Vol. 3\\000.png'
[ERROR] Unhandled exception, FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Ethan\\Downloads\\Kobo-pine\\New Normal\\Vol. 3\\000.png'
Traceback (most recent call last):
  File "C:\Users\Ethan\AppData\Local\Programs\Python\Python311\Lib\site-packages\mangadex_downloader\cli\__init__.py", line 76, in _main
    download(args)
  File "C:\Users\Ethan\AppData\Local\Programs\Python\Python311\Lib\site-packages\mangadex_downloader\cli\download.py", line 33, in download
    url(args, args.type)
  File "C:\Users\Ethan\AppData\Local\Programs\Python\Python311\Lib\site-packages\mangadex_downloader\cli\url.py", line 166, in __call__
    self.func(self.id, args)
  File "C:\Users\Ethan\AppData\Local\Programs\Python\Python311\Lib\site-packages\mangadex_downloader\cli\url.py", line 97, in download_manga
    dl_manga(*args)
  File "C:\Users\Ethan\AppData\Local\Programs\Python\Python311\Lib\site-packages\mangadex_downloader\main.py", line 167, in download
    download_manga(manga, base_path)
  File "C:\Users\Ethan\AppData\Local\Programs\Python\Python311\Lib\site-packages\mangadex_downloader\main.py", line 137, in download_manga
    fmt.main()
  File "C:\Users\Ethan\AppData\Local\Programs\Python\Python311\Lib\site-packages\mangadex_downloader\format\base.py", line 697, in main
    self.download_volumes(volumes)
  File "C:\Users\Ethan\AppData\Local\Programs\Python\Python311\Lib\site-packages\mangadex_downloader\format\base.py", line 625, in download_volumes     
    self.on_finish(file_path, volume, images)
  File "C:\Users\Ethan\AppData\Local\Programs\Python\Python311\Lib\site-packages\mangadex_downloader\format\pdf.py", line 454, in on_finish
    self.worker.submit(lambda: self.convert(self.images, file_path))
  File "C:\Users\Ethan\AppData\Local\Programs\Python\Python311\Lib\site-packages\mangadex_downloader\utils.py", line 196, in submit
    raise err
  File "C:\Users\Ethan\AppData\Local\Programs\Python\Python311\Lib\site-packages\mangadex_downloader\utils.py", line 217, in run
    job()
  File "C:\Users\Ethan\AppData\Local\Programs\Python\Python311\Lib\site-packages\mangadex_downloader\format\pdf.py", line 454, in <lambda>
    self.worker.submit(lambda: self.convert(self.images, file_path))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ethan\AppData\Local\Programs\Python\Python311\Lib\site-packages\mangadex_downloader\format\pdf.py", line 392, in convert
    im = im_ref()
         ^^^^^^^^
  File "C:\Users\Ethan\AppData\Local\Programs\Python\Python311\Lib\site-packages\mangadex_downloader\format\pdf.py", line 68, in __call__
    return self._func(*self._args, **self._kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Ethan\AppData\Local\Programs\Python\Python311\Lib\site-packages\PIL\Image.py", line 3236, in open
    fp = builtins.open(filename, "rb")
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Ethan\\Downloads\\Kobo-pine\\New Normal\\Vol. 3\\000.png'

What did you expect to happen ?

I expected the program to convert the Folders into a PDF, in the same way as the cbz method

OS version

Windows 10

App version

mangadex-downloader v2.10.1 (https://github.com/mansuf/mangadex-downloader) Python: 3.11.2 arch: x64 bundled executable: no

Installation origin

PyPI (Python Package Index)

Installation origin (other sources)

No response

Reproducible command

mangadex-dl https://mangadex.org/title/e1d0056a-fdd3-4f32-af19-50eeb37280ac --save-as "pdf-volume" --use-volume-cover -uvc --progress-bar-layout=none

Additional context

if you repeatedly do the same command over and over every time it crashes it will eventually get through all the chapters (using the download.db I'm guessing)

mansuf commented 1 year ago

Man, seems like i messed up when refactoring codes. Sorry about that, i've made PR #79 to fix this issue. You can test it by installing patched version.

Please note that you need git to install patched version

# Make sure you uninstall previous version mangadex-downloader
pip uninstall mangadex-downloader

# Install patched version
pip install -U git+https://github.com/mansuf/mangadex-downloader.git@e4b4e456ca9188d305c1af443a4c947bae570646

The issue was caused by images that want to be converted but the images already been deleted. If you're curious what code has causing this.

https://github.com/mansuf/mangadex-downloader/blob/206f5cfb3226c4f3bb93c8972c6a4d11c407d233/mangadex_downloader/format/pdf.py#L440

Technically PDFVolume.images has been used to store downloaded images for each volumes and after that the application will convert to pdf and delete the images. The problem is PDFVolume.images values never been cleared after previous volumes has been converted, so it will trying to convert images to pdf from previous volumes.

Ethaisa123 commented 1 year ago

oh nice works perfectly now, thanks man.