Downloaders

Downloaders are responsible for fetching manga pages from the internet. The need for custom downloaders arises when dealing with unique source requirements, such as specific request headers, handling CAPTCHAs, or optimizing download speeds.

Implementation

To create a custom downloader, you must implement the IDownloaderAdapter abstract base class (ABC). This class requires the implementation of a single method, download, which takes a manga Image object as input and returns a BytesIO object containing the image data.

Example

from abc import ABC, abstractmethod
from io import BytesIO
from enma.domain.entities.manga import Image
import requests

class CustomDownloader(IDownloaderAdapter):

    @abstractmethod
    def download(self, page: Image) -> BytesIO:
        response = requests.get(page.uri)
        if response.status_code == 200:
            return BytesIO(response.content)
        else:
            raise Exception(f"Failed to download page: {page.uri}")

Last updated