CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-jmcomic

Python API for accessing and downloading content from JMComic with Cloudflare bypass and plugin system.

Pending
Overview
Eval results
Files

core-download-api.mddocs/

Core Download API

High-level download functions that provide the main interface for downloading albums and photos from JMComic. These functions handle automatic retry, error checking, and batch processing with multi-threading support.

Capabilities

Album Download

Downloads a complete manga album including all chapters/photos with metadata. Supports both single album downloads and batch processing.

def download_album(jm_album_id, option=None, downloader=None, callback=None, check_exception=True):
    """
    Download a complete album (manga) including all chapters.
    
    Parameters:
    - jm_album_id: str or int or iterable - Album ID(s) to download
    - option: JmOption, optional - Download configuration options
    - downloader: JmDownloader class, optional - Custom downloader class
    - callback: callable, optional - Callback function for completion events
    - check_exception: bool - Whether to check and raise download exceptions
    
    Returns:
    Union[Tuple[JmAlbumDetail, JmDownloader], Set[Tuple[JmAlbumDetail, JmDownloader]]]
    - Single album: (JmAlbumDetail, JmDownloader) tuple
    - Multiple albums: Set of (JmAlbumDetail, JmDownloader) tuples
    """

Usage examples:

# Download single album
album, downloader = download_album("123456")

# Download with custom options
option = create_option_by_file("config.yml")
album, downloader = download_album("123456", option=option)

# Download multiple albums (batch mode)
album_ids = ["123456", "789012", "345678"]
results = download_album(album_ids, option=option)

# Download with callback
def on_complete(album, downloader):
    print(f"Completed: {album.title}")

album, downloader = download_album("123456", callback=on_complete)

Photo Download

Downloads a single chapter/photo with all its images. Supports both individual photo downloads and batch processing.

def download_photo(jm_photo_id, option=None, downloader=None, callback=None, check_exception=True):
    """
    Download a single chapter/photo with all images.
    
    Parameters:
    - jm_photo_id: str or int or iterable - Photo ID(s) to download
    - option: JmOption, optional - Download configuration options
    - downloader: JmDownloader class, optional - Custom downloader class
    - callback: callable, optional - Callback function for completion events
    - check_exception: bool - Whether to check and raise download exceptions
    
    Returns:
    Union[Tuple[JmPhotoDetail, JmDownloader], Set[Tuple[JmPhotoDetail, JmDownloader]]]
    - Single photo: (JmPhotoDetail, JmDownloader) tuple
    - Multiple photos: Set of (JmPhotoDetail, JmDownloader) tuples
    """

Usage examples:

# Download single photo
photo, downloader = download_photo("456789")

# Download multiple photos (batch mode)
photo_ids = ["456789", "012345", "678901"]
results = download_photo(photo_ids)

Batch Download

Processes multiple downloads concurrently using multi-threading. Each item gets its own thread and uses the same configuration options.

def download_batch(download_api, jm_id_iter, option=None, downloader=None):
    """
    Download multiple albums or photos concurrently.
    
    Parameters:
    - download_api: callable - Download function (download_album or download_photo)
    - jm_id_iter: iterable - Iterator of JM IDs to download
    - option: JmOption, optional - Shared download configuration
    - downloader: JmDownloader class, optional - Downloader class for all downloads
    
    Returns:
    Set[Tuple[Union[JmAlbumDetail, JmPhotoDetail], JmDownloader]]
    Set of (entity, downloader) tuples for each completed download
    """

Usage examples:

# Download multiple albums concurrently
album_ids = ["123456", "789012", "345678"]
results = download_batch(download_album, album_ids)

# Download multiple photos concurrently
photo_ids = ["456789", "012345", "678901"]
results = download_batch(download_photo, photo_ids)

# Process results
for entity, downloader in results:
    print(f"Downloaded: {entity.title}")
    if downloader.has_exception():
        print(f"  Errors: {len(downloader.exception_list)}")

Downloader Creation

Creates new downloader instances with specified configuration options.

def new_downloader(option=None, downloader=None):
    """
    Create a new downloader instance.
    
    Parameters:
    - option: JmOption, optional - Configuration options (uses default if None)
    - downloader: JmDownloader class, optional - Downloader class (uses default if None)
    
    Returns:
    JmDownloader - Configured downloader instance
    """

Usage examples:

# Create downloader with default settings
downloader = new_downloader()

# Create downloader with custom options
option = create_option_by_file("config.yml")
downloader = new_downloader(option=option)

# Use custom downloader class
from jmcomic import DoNotDownloadImage
test_downloader = new_downloader(downloader=DoNotDownloadImage)

Error Handling

All download functions support the check_exception parameter (default: True) to control exception handling:

  • True: Raises PartialDownloadFailedException if any downloads fail
  • False: Returns results without raising exceptions; check downloader.has_exception()
# Strict error checking (default)
try:
    album, downloader = download_album("123456")
except PartialDownloadFailedException as e:
    print(f"Download failed: {e}")

# Lenient error checking
album, downloader = download_album("123456", check_exception=False)
if downloader.has_exception():
    print(f"Errors occurred: {len(downloader.exception_list)}")

Install with Tessl CLI

npx tessl i tessl/pypi-jmcomic

docs

client-system.md

command-line-interface.md

configuration-management.md

content-entities.md

core-download-api.md

download-system.md

exception-handling.md

index.md

plugin-system.md

text-data-processing.md

tile.json