Downloading Chapters

Enma provides a robust way to download manga chapters directly to your local storage or any compatible storage system through the ISaverAdapter interface. This feature is essential for users looking to create offline manga collections or manage large volumes of manga data efficiently.

Requirements

Before proceeding, ensure you have Enma set up and configured to use the manganato source. You will also need to have a manga identifier for the manga you wish to download chapters from.

Download Setup

The following components are crucial for downloading chapters

  • Downloader: Responsible for fetching chapter pages from the source.

  • Saver: Defines where and how downloaded pages are saved.

  • Threaded Download: Optimize download performance using multiple threads.

Example

Here's how you can download a chapter using Enma:

from enma import (Enma, CloudFlareConfig, ManganatoDownloader, Threaded, LocalStorage)

enma = Enma()
enma.source_manager.set_source('manganato')
manga = enma.get(identifier='manga-wb999684')

downloader = ManganatoDownloader()
local_storage = LocalStorage()

if manga:
    enma.download_chapter(path=f'./download/{manga.title.english}',
                          chapter=manga.chapters[0],
                          downloader=downloader,
                          saver=local_storage,
                          threaded=Threaded(use_threads=True, number_of_threads=5))

download_chapter Function Explained

Key Components

  • Threaded: A data class to manage threaded downloads, including whether to use threading and the number of threads.

  • DownloadChapterRequestDTO: Contains all necessary data for downloading a chapter, such as the chapter itself, path to save, downloader, saver, and threading details.

  • DownloadChapterUseCase: Orchestrates the downloading process, handling both threaded and synchronous downloads.

How It Works

  1. Setup: Initialize the downloader, saver, and threading preferences.

  2. Download: Pages are downloaded either in a synchronous manner or using a ThreadPoolExecutor for threaded downloads.

  3. Save: A separate thread(s) saves downloaded pages to the specified storage, using the saver adapter.

Handling Downloads and Saves

The process uses a queue to manage downloaded pages, ensuring that saving to storage happens even as downloads continue. This is particularly efficient when using threads, as it allows for concurrent downloading and saving, speeding up the overall process.

Conclusion

Using Enma to download manga chapters is a powerful and flexible way to manage manga collections. By leveraging threading and customizable saving options, users can efficiently download large volumes of manga data for offline viewing or archival purposes.

Last updated