cbz


Namecbz JSON
Version 3.3.5 PyPI version JSON
download
home_pageNone
SummaryCBZ simplifies creating, managing, and viewing comic book files in CBZ format, offering seamless packaging, metadata handling, and built-in viewing capabilities
upload_time2024-07-22 17:53:00
maintainerNone
docs_urlNone
authorhyugogirubato
requires_python<4.0,>=3.8
licenseMIT
keywords python cbz ebooks manga comics webtoons
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CBZ

CBZ is a Python library designed for creating, manipulating, and viewing comic book files in CBZ format. It offers a straightforward interface to pack comic pages into CBZ archives, extract metadata, and display comics using a built-in player.

## Features

- 🚀 Seamless Installation via [pip](#installation)
- 📚 Pack images into CBZ format for comics and manga
- 📝 Extract and manage title, series, format, and more
- 🖼️ Handle comic pages with attributes like type and format
- 📦 Unpack CBZ files to retrieve comic information
- 🛠️ Built-in player for viewing CBZ comics
- ❤️ Fully Open-Source! Pull Requests Welcome

## Installation

Install KeyDive from PyPI using Poetry:

```shell
pip install cbz
```

## Quick Start

Here's a quick example of how to create a CBZ file from a series of images:

````python
from pathlib import Path

from cbz.comic import ComicInfo
from cbz.constants import PageType, YesNo, Manga, AgeRating, Format
from cbz.page import PageInfo

PARENT = Path(__file__).parent

if __name__ == '__main__':
    paths = list(Path('path/to/your/images').iterdir())

    # Load each page from the 'images' folder into a list of PageInfo objects
    pages = [
        PageInfo.load(
            path=path,
            type=PageType.FRONT_COVER if i == 0 else PageType.BACK_COVER if i == len(paths) - 1 else PageType.STORY
        )
        for i, path in enumerate(paths)
    ]

    # Create a ComicInfo object using ComicInfo.from_pages() method
    comic = ComicInfo.from_pages(
        pages=pages,
        title='Your Comic Title',
        series='Your Comic Series',
        number=1,
        language_iso='en',
        format=Format.WEB_COMIC,
        black_white=YesNo.NO,
        manga=Manga.NO,
        age_rating=AgeRating.PENDING
    )

    # Show the comic using the show()
    comic.show()

    # Pack the comic book content into a CBZ file format
    cbz_content = comic.pack()

    # Define the path where the CBZ file will be saved
    cbz_path = PARENT / 'your_comic.cbz'

    # Write the CBZ content to the specified path
    cbz_path.write_bytes(cbz_content)
````

## Player

CBZ includes a command-line player for viewing CBZ comic book files. Simply run cbzplayer <file> to launch the player with the specified CBZ file.

````shell
usage: cbzplayer [-h] <file>

Launch CBZ player with a comic book file

positional arguments:
  <file>      Path to the CBZ comic book file.

options:
  -h, --help  show this help message and exit

````

## Detailed Usage

### Creating a ComicInfo Object

The `ComicInfo` class represents a comic book with metadata and pages. It supports initialization from a list of `PageInfo` objects:

```python
from cbz.comic import ComicInfo
from cbz.page import PageInfo

# Example usage:
pages = [
    PageInfo.load(path='/path/to/page1.jpg', type=PageType.FRONT_COVER),
    PageInfo.load(path='/path/to/page2.jpg', type=PageType.STORY),
    PageInfo.load(path='/path/to/page3.jpg', type=PageType.BACK_COVER),
]

comic = ComicInfo.from_pages(
    pages=pages,
    title='My Comic',
    series='Comic Series',
    number=1,
    language_iso='en',
    format=Format.WEB_COMIC,
    black_white=YesNo.NO,
    manga=Manga.NO,
    age_rating=AgeRating.PENDING
)
```

### Extracting Metadata

Retrieve comic information as a dictionary using `get_info()`:

```python
info = comic.get_info()
print(info)
```

### Packing into CBZ Format

Pack the comic into a CBZ file format:

```python
cbz_content = comic.pack()
```

### Unpacking from CBZ

Load a comic from an existing CBZ file:

```python
comic_from_cbz = ComicInfo.from_cbz('/path/to/your_comic.cbz')
```

## Contributors

<a href="https://github.com/hyugogirubato"><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/65763543?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="hyugogirubato"/></a>
<a href="https://github.com/piskunqa"><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/38443069?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="piskunqa"/></a>
<a href="https://github.com/OleskiiPyskun"><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/75667382?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="OleskiiPyskun"/></a>
<a href="https://github.com/domenicoblanco"><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/9018104?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="domenicoblanco"/></a>
<a href="https://github.com/RivMt"><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/40086827?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="RivMt"/></a>
<a href="https://github.com/flolep2607"><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/24566964?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="flolep2607"/></a>
<a href="https://github.com/gokender"><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/3709740?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="gokender"/></a>


## Licensing

This software is licensed under the terms of [MIT License](https://github.com/hyugogirubato/cbz/blob/main/LICENSE).  
You can find a copy of the license in the LICENSE file in the root folder.

* * * 

© hyugogirubato 2024
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cbz",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "python, cbz, ebooks, manga, comics, webtoons",
    "author": "hyugogirubato",
    "author_email": "65763543+hyugogirubato@users.noreply.github.com",
    "download_url": "https://files.pythonhosted.org/packages/40/c3/46b3640aa78850eb802c0e2a1e29390285e1834f544eeeacb3325f6c2ea3/cbz-3.3.5.tar.gz",
    "platform": null,
    "description": "# CBZ\n\nCBZ is a Python library designed for creating, manipulating, and viewing comic book files in CBZ format. It offers a straightforward interface to pack comic pages into CBZ archives, extract metadata, and display comics using a built-in player.\n\n## Features\n\n- \ud83d\ude80 Seamless Installation via [pip](#installation)\n- \ud83d\udcda Pack images into CBZ format for comics and manga\n- \ud83d\udcdd Extract and manage title, series, format, and more\n- \ud83d\uddbc\ufe0f Handle comic pages with attributes like type and format\n- \ud83d\udce6 Unpack CBZ files to retrieve comic information\n- \ud83d\udee0\ufe0f Built-in player for viewing CBZ comics\n- \u2764\ufe0f Fully Open-Source! Pull Requests Welcome\n\n## Installation\n\nInstall KeyDive from PyPI using Poetry:\n\n```shell\npip install cbz\n```\n\n## Quick Start\n\nHere's a quick example of how to create a CBZ file from a series of images:\n\n````python\nfrom pathlib import Path\n\nfrom cbz.comic import ComicInfo\nfrom cbz.constants import PageType, YesNo, Manga, AgeRating, Format\nfrom cbz.page import PageInfo\n\nPARENT = Path(__file__).parent\n\nif __name__ == '__main__':\n    paths = list(Path('path/to/your/images').iterdir())\n\n    # Load each page from the 'images' folder into a list of PageInfo objects\n    pages = [\n        PageInfo.load(\n            path=path,\n            type=PageType.FRONT_COVER if i == 0 else PageType.BACK_COVER if i == len(paths) - 1 else PageType.STORY\n        )\n        for i, path in enumerate(paths)\n    ]\n\n    # Create a ComicInfo object using ComicInfo.from_pages() method\n    comic = ComicInfo.from_pages(\n        pages=pages,\n        title='Your Comic Title',\n        series='Your Comic Series',\n        number=1,\n        language_iso='en',\n        format=Format.WEB_COMIC,\n        black_white=YesNo.NO,\n        manga=Manga.NO,\n        age_rating=AgeRating.PENDING\n    )\n\n    # Show the comic using the show()\n    comic.show()\n\n    # Pack the comic book content into a CBZ file format\n    cbz_content = comic.pack()\n\n    # Define the path where the CBZ file will be saved\n    cbz_path = PARENT / 'your_comic.cbz'\n\n    # Write the CBZ content to the specified path\n    cbz_path.write_bytes(cbz_content)\n````\n\n## Player\n\nCBZ includes a command-line player for viewing CBZ comic book files. Simply run cbzplayer <file> to launch the player with the specified CBZ file.\n\n````shell\nusage: cbzplayer [-h] <file>\n\nLaunch CBZ player with a comic book file\n\npositional arguments:\n  <file>      Path to the CBZ comic book file.\n\noptions:\n  -h, --help  show this help message and exit\n\n````\n\n## Detailed Usage\n\n### Creating a ComicInfo Object\n\nThe `ComicInfo` class represents a comic book with metadata and pages. It supports initialization from a list of `PageInfo` objects:\n\n```python\nfrom cbz.comic import ComicInfo\nfrom cbz.page import PageInfo\n\n# Example usage:\npages = [\n    PageInfo.load(path='/path/to/page1.jpg', type=PageType.FRONT_COVER),\n    PageInfo.load(path='/path/to/page2.jpg', type=PageType.STORY),\n    PageInfo.load(path='/path/to/page3.jpg', type=PageType.BACK_COVER),\n]\n\ncomic = ComicInfo.from_pages(\n    pages=pages,\n    title='My Comic',\n    series='Comic Series',\n    number=1,\n    language_iso='en',\n    format=Format.WEB_COMIC,\n    black_white=YesNo.NO,\n    manga=Manga.NO,\n    age_rating=AgeRating.PENDING\n)\n```\n\n### Extracting Metadata\n\nRetrieve comic information as a dictionary using `get_info()`:\n\n```python\ninfo = comic.get_info()\nprint(info)\n```\n\n### Packing into CBZ Format\n\nPack the comic into a CBZ file format:\n\n```python\ncbz_content = comic.pack()\n```\n\n### Unpacking from CBZ\n\nLoad a comic from an existing CBZ file:\n\n```python\ncomic_from_cbz = ComicInfo.from_cbz('/path/to/your_comic.cbz')\n```\n\n## Contributors\n\n<a href=\"https://github.com/hyugogirubato\"><img src=\"https://images.weserv.nl/?url=avatars.githubusercontent.com/u/65763543?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d\" alt=\"hyugogirubato\"/></a>\n<a href=\"https://github.com/piskunqa\"><img src=\"https://images.weserv.nl/?url=avatars.githubusercontent.com/u/38443069?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d\" alt=\"piskunqa\"/></a>\n<a href=\"https://github.com/OleskiiPyskun\"><img src=\"https://images.weserv.nl/?url=avatars.githubusercontent.com/u/75667382?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d\" alt=\"OleskiiPyskun\"/></a>\n<a href=\"https://github.com/domenicoblanco\"><img src=\"https://images.weserv.nl/?url=avatars.githubusercontent.com/u/9018104?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d\" alt=\"domenicoblanco\"/></a>\n<a href=\"https://github.com/RivMt\"><img src=\"https://images.weserv.nl/?url=avatars.githubusercontent.com/u/40086827?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d\" alt=\"RivMt\"/></a>\n<a href=\"https://github.com/flolep2607\"><img src=\"https://images.weserv.nl/?url=avatars.githubusercontent.com/u/24566964?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d\" alt=\"flolep2607\"/></a>\n<a href=\"https://github.com/gokender\"><img src=\"https://images.weserv.nl/?url=avatars.githubusercontent.com/u/3709740?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d\" alt=\"gokender\"/></a>\n\n\n## Licensing\n\nThis software is licensed under the terms of [MIT License](https://github.com/hyugogirubato/cbz/blob/main/LICENSE).  \nYou can find a copy of the license in the LICENSE file in the root folder.\n\n* * * \n\n\u00a9 hyugogirubato 2024",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "CBZ simplifies creating, managing, and viewing comic book files in CBZ format, offering seamless packaging, metadata handling, and built-in viewing capabilities",
    "version": "3.3.5",
    "project_urls": {
        "Changelog": "https://github.com/hyugogirubato/cbz/blob/main/CHANGELOG.md",
        "Issues": "https://github.com/hyugogirubato/cbz/issues"
    },
    "split_keywords": [
        "python",
        " cbz",
        " ebooks",
        " manga",
        " comics",
        " webtoons"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eaf455071d3045ff0f159a9c0ca259c1375c999d8b1929d4dafd5fe8b45a8597",
                "md5": "3dced697f45633d87699ffa20bce0fef",
                "sha256": "9d5a4af280c3e580b9c0a704766b46106cdfd3ac969a960be786c00bc8fd1243"
            },
            "downloads": -1,
            "filename": "cbz-3.3.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3dced697f45633d87699ffa20bce0fef",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 66774,
            "upload_time": "2024-07-22T17:52:59",
            "upload_time_iso_8601": "2024-07-22T17:52:59.228564Z",
            "url": "https://files.pythonhosted.org/packages/ea/f4/55071d3045ff0f159a9c0ca259c1375c999d8b1929d4dafd5fe8b45a8597/cbz-3.3.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "40c346b3640aa78850eb802c0e2a1e29390285e1834f544eeeacb3325f6c2ea3",
                "md5": "200290e80cbda148917f48efa12ff588",
                "sha256": "903ccd49d9f4586c620dd20b8cdc2d11d34a6145aeb04058c3b7f19ea7acb4ee"
            },
            "downloads": -1,
            "filename": "cbz-3.3.5.tar.gz",
            "has_sig": false,
            "md5_digest": "200290e80cbda148917f48efa12ff588",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 66733,
            "upload_time": "2024-07-22T17:53:00",
            "upload_time_iso_8601": "2024-07-22T17:53:00.871254Z",
            "url": "https://files.pythonhosted.org/packages/40/c3/46b3640aa78850eb802c0e2a1e29390285e1834f544eeeacb3325f6c2ea3/cbz-3.3.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-22 17:53:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hyugogirubato",
    "github_project": "cbz",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "cbz"
}
        
Elapsed time: 0.32865s