Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a622ac7b7 | ||
|
|
5ae089239a | ||
|
|
95472d4ac4 | ||
|
|
0ecf0f843b | ||
|
|
4d4d367791 | ||
|
|
caead0a957 | ||
|
|
d37be87c2f | ||
|
|
0b011a7efc | ||
|
|
62b8cf5739 | ||
|
|
871716971a | ||
|
|
597cb41b00 | ||
|
|
a489ae17fb | ||
|
|
abc69d4673 | ||
|
|
6a1111a6bb | ||
|
|
220f19fe46 | ||
|
|
bbab9ba3b3 | ||
|
|
5824a8428a | ||
|
|
23f7e37561 | ||
|
|
5cc4732238 | ||
|
|
9d5d539311 | ||
|
|
f8274ae26b | ||
|
|
c045c548de | ||
|
|
7355e5edc0 | ||
|
|
5eee972d75 | ||
|
|
3604a4e98f | ||
|
|
19c1b01ea6 | ||
|
|
7e599a1adb | ||
|
|
312eb2da13 | ||
|
|
b7d1b631b9 | ||
|
|
fe43024656 | ||
|
|
58a5256dc1 | ||
|
|
7d0f004345 | ||
|
|
6aeabc2047 | ||
|
|
46b508adf8 | ||
|
|
6d771e3bf8 | ||
|
|
0c4aa34f8f | ||
|
|
48c99ba44f | ||
|
|
8af1c47e15 | ||
|
|
6aa6b0da21 | ||
|
|
526fee3617 | ||
|
|
6354c1d3bb | ||
|
|
3a80dfe47b | ||
|
|
58ef27f227 | ||
|
|
36b76f6d9e | ||
|
|
3c53f16d07 | ||
|
|
8161551ab6 | ||
|
|
8ab1b37332 | ||
|
|
784f698044 | ||
|
|
fc1e693e67 | ||
|
|
4d831f28a9 | ||
|
|
195fca4370 | ||
|
|
758e54fa4d | ||
|
|
7f1a0724e1 | ||
|
|
f015d998e1 | ||
|
|
7d82752546 | ||
|
|
e8e6eaf3ae | ||
|
|
4f777bc9bf | ||
|
|
c48d64cbe0 | ||
|
|
d195e25043 | ||
|
|
5fd7c019d1 | ||
|
|
c4169ebb84 | ||
|
|
a46bae2e2d | ||
|
|
616b1eff8e | ||
|
|
27a313fe4c | ||
|
|
72c14449fc | ||
|
|
04feaa7027 | ||
|
|
8b8069e38d | ||
|
|
d357ad3e1d | ||
|
|
b234a46e00 | ||
|
|
e6d77739e1 | ||
|
|
0421d99c44 | ||
|
|
17084154a4 | ||
|
|
cba561c2ec | ||
|
|
0b21040b95 | ||
|
|
f52e112de9 | ||
|
|
2435ca396d | ||
|
|
5bc82581a3 | ||
|
|
188b2e0164 | ||
|
|
04b77d5ff9 | ||
|
|
3f777d30d6 | ||
|
|
6847e7f281 | ||
|
|
15d7aaa094 | ||
|
|
7800205e87 | ||
|
|
963ecf9e6f | ||
|
|
baee10d922 | ||
|
|
140fd6c107 | ||
|
|
7fceb86a7b | ||
|
|
eec284a3ef | ||
|
|
fe6d92229c | ||
|
|
413f9d498e | ||
|
|
a90d9abf75 | ||
|
|
4fe38f0d5a | ||
|
|
153f5f79c5 | ||
|
|
0947e1904b | ||
|
|
7f1060fc30 | ||
|
|
df54489eef | ||
|
|
68e843af63 | ||
|
|
4b2c47b4b8 | ||
|
|
74a6a0e9b6 | ||
|
|
82e1764c2e | ||
|
|
f62a508d9a | ||
|
|
90abd137c5 | ||
|
|
bf735138b3 | ||
|
|
17ccc50359 | ||
|
|
721cfeaf7d | ||
|
|
baeb110a93 | ||
|
|
6a3f1fefbb | ||
|
|
a59356779d | ||
|
|
9902a7872d | ||
|
|
7b85489bd0 | ||
|
|
9ef572f05e | ||
|
|
9dced03251 | ||
|
|
0f9cf550a3 | ||
|
|
f069f73fb0 | ||
|
|
28f5b95e6f | ||
|
|
b9ba454cbe | ||
|
|
bdda6864d4 | ||
|
|
9549a375a3 | ||
|
|
2a508f0265 | ||
|
|
5515fd3660 | ||
|
|
121fc7244a | ||
|
|
c9540e868f | ||
|
|
0aaa730b6c | ||
|
|
79ebbb3c0d | ||
|
|
f4448b9e82 | ||
|
|
7ca3bfce14 | ||
|
|
cc2db78052 | ||
|
|
1013dc9131 | ||
|
|
a005ef8127 | ||
|
|
0e3e3840c7 | ||
|
|
4fbb7fd73a | ||
|
|
2edbd2f0c7 | ||
|
|
75ceec8a44 | ||
|
|
af878ca167 | ||
|
|
ea59025499 | ||
|
|
da535bdc67 | ||
|
|
c9a4d94816 | ||
|
|
17ceafb384 | ||
|
|
ac00ee20a3 | ||
|
|
cc974077e3 | ||
|
|
eebe00ee5c | ||
|
|
6bef8e8de2 | ||
|
|
fe4bb165d4 | ||
|
|
8eaff56f6a | ||
|
|
1f1433a3c4 | ||
|
|
ffca3239cf | ||
|
|
a57f1c96a8 | ||
|
|
f5debc6f56 | ||
|
|
40cb3759f2 | ||
|
|
9ff1f4940c | ||
|
|
11aada0be7 |
@@ -0,0 +1,11 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "pip"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
@@ -0,0 +1,27 @@
|
||||
name: Tests
|
||||
|
||||
on: [ push, pull_request ]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v7
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
pip install poetry
|
||||
poetry install --no-interaction --no-root --with dev
|
||||
|
||||
- name: Run tests with pytest
|
||||
run: |
|
||||
poetry run pytest tests/ -v --cov=cbz --cov-report=xml --cov-report=term-missing
|
||||
@@ -1,6 +1,8 @@
|
||||
# Created by https://github.com/github/gitignore/blob/main/Python.gitignore
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*.py[codz]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
@@ -8,7 +10,6 @@ __pycache__/
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
@@ -21,13 +22,15 @@ parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
@@ -38,13 +41,17 @@ pip-delete-this-directory.txt
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py.cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
@@ -53,6 +60,8 @@ coverage.xml
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
@@ -65,27 +74,90 @@ instance/
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# celery beat schedule file
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
# Pipfile.lock
|
||||
|
||||
# UV
|
||||
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
# uv.lock
|
||||
|
||||
# poetry
|
||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||
# poetry.lock
|
||||
# poetry.toml
|
||||
|
||||
# pdm
|
||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
||||
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
||||
# pdm.lock
|
||||
# pdm.toml
|
||||
.pdm-python
|
||||
.pdm-build/
|
||||
|
||||
# pixi
|
||||
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
||||
# pixi.lock
|
||||
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
||||
# in the .venv directory. It is recommended not to include this directory in version control.
|
||||
.pixi
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# Redis
|
||||
*.rdb
|
||||
*.aof
|
||||
*.pid
|
||||
|
||||
# RabbitMQ
|
||||
mnesia/
|
||||
rabbitmq/
|
||||
rabbitmq-data/
|
||||
|
||||
# ActiveMQ
|
||||
activemq-data/
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# dotenv
|
||||
# Environments
|
||||
.env
|
||||
|
||||
# virtualenv
|
||||
.envrc
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
@@ -99,3 +171,54 @@ ENV/
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
# PyCharm
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
.idea/
|
||||
|
||||
# Abstra
|
||||
# Abstra is an AI-powered process automation framework.
|
||||
# Ignore directories containing user credentials, local state, and settings.
|
||||
# Learn more at https://abstra.io/docs
|
||||
.abstra/
|
||||
|
||||
# Visual Studio Code
|
||||
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
||||
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
||||
# you could uncomment the following to ignore the entire vscode folder
|
||||
# .vscode/
|
||||
|
||||
# Ruff stuff:
|
||||
.ruff_cache/
|
||||
|
||||
# PyPI configuration file
|
||||
.pypirc
|
||||
|
||||
# Marimo
|
||||
marimo/_static/
|
||||
marimo/_lsp/
|
||||
__marimo__/
|
||||
|
||||
# Streamlit
|
||||
.streamlit/secrets.toml
|
||||
|
||||
#CBZ
|
||||
*.cbz
|
||||
*.pdf
|
||||
*.zip
|
||||
*.cbr
|
||||
@@ -1,23 +0,0 @@
|
||||
language: python
|
||||
matrix:
|
||||
include:
|
||||
- python: 3.4
|
||||
dist: trusty
|
||||
sudo: false
|
||||
- python: 3.5
|
||||
dist: trusty
|
||||
sudo: false
|
||||
- python: 3.5-dev
|
||||
dist: trusty
|
||||
sudo: false
|
||||
- python: 3.6
|
||||
dist: trusty
|
||||
sudo: false
|
||||
- python: 3.6-dev
|
||||
dist: trusty
|
||||
sudo: false
|
||||
- python: 3.7
|
||||
dist: xenial
|
||||
sudo: true
|
||||
install:
|
||||
- python setup.py -q install
|
||||
@@ -0,0 +1,308 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [4.0.0] - 2026-04-06
|
||||
|
||||
### Added
|
||||
|
||||
- Dataclass-based models (`ComicModel`, `PageModel`) with automatic XML field mapping via `xml_field()` metadata.
|
||||
- Sequence protocol on `ComicInfo`: `len(comic)`, `comic[i]`, `comic[0:3]`, `for page in comic`, `page in comic`.
|
||||
- Custom exception hierarchy: `CBZError`, `InvalidImageError`, `EmptyArchiveError`, `InvalidMetadataError`, `UnsupportedFormatError`.
|
||||
- `__version__` attribute exported from the `cbz` package.
|
||||
- Simplified top-level imports: `from cbz import ComicInfo, PageInfo, PageType, Format, ...`.
|
||||
- Complete CBZ format RFC specification in `docs/RFC-CBZ.md`.
|
||||
- `save()` now writes directly to disk (more memory-efficient for large archives).
|
||||
- Type hints cached with `lru_cache` for faster archive loading with many pages.
|
||||
|
||||
### Changed
|
||||
|
||||
- **Python 3.9+ required** (previously 3.8+).
|
||||
- `ComicModel` and `PageModel` rewritten as `@dataclass` classes (replaces custom `BaseModel` with field dictionaries).
|
||||
- All enumerations now inherit from `StrEnum` (backported `str, Enum` mixin for Python < 3.11).
|
||||
- Optional numeric fields (`number`, `year`, `volume`, etc.) now default to `None` instead of `-1`.
|
||||
- `Rating` validates `0.0-5.0` with `ValueError` instead of `assert` (default `0.0` instead of `-1`).
|
||||
- `LanguageISO` raises `ValueError` instead of `AssertionError` for invalid codes.
|
||||
- Removed `utils.verify_attr`, `utils.default_attr`, `utils.repr_attr` (replaced by dataclass defaults and enum handling).
|
||||
- Removed `COMIC_FIELDS` and `PAGE_FIELDS` dictionaries (replaced by dataclass field metadata).
|
||||
- `save()` writes directly to a file-backed `ZipFile` instead of going through an in-memory buffer.
|
||||
- All documentation, docstrings and comments rewritten in English.
|
||||
|
||||
### Renamed
|
||||
|
||||
- `Manga.RIGHT_LEFT` -> `Manga.YES_AND_RIGHT_TO_LEFT`
|
||||
- `AgeRating.ADULTS18` -> `AgeRating.ADULTS_ONLY_18_PLUS`
|
||||
- `AgeRating.CHILDHOOD` -> `AgeRating.EARLY_CHILDHOOD`
|
||||
- `AgeRating.EVERYONE10` -> `AgeRating.EVERYONE_10_PLUS`
|
||||
- `AgeRating.KIDS` -> `AgeRating.KIDS_TO_ADULTS`
|
||||
- `AgeRating.MA15` -> `AgeRating.MA15_PLUS`
|
||||
- `AgeRating.MATURE17` -> `AgeRating.MATURE_17_PLUS`
|
||||
- `AgeRating.R18` -> `AgeRating.R18_PLUS`
|
||||
- `AgeRating.PENDING` -> `AgeRating.RATING_PENDING`
|
||||
- `AgeRating.X18` -> `AgeRating.X18_PLUS`
|
||||
- `Format.BLACK_WHITE` -> `Format.BLACK_AND_WHITE`
|
||||
- `Format.DIRECTOR_CUT` -> `Format.DIRECTORS_CUT`
|
||||
- `Format.TRADE_PAPER_BACK` -> `Format.TRADE_PAPERBACK`
|
||||
- `Format.POINT1` -> `Format.POINT_ONE`
|
||||
- `IMAGE_FORMAT` -> `IMAGE_FORMATS`
|
||||
|
||||
### Fixed
|
||||
|
||||
- Image resource leak in the player when navigating pages.
|
||||
- ICO-to-PNG conversion resource leak in `utils.ico_to_png`.
|
||||
- `data.strip()` in `PageInfo.loads()` no longer copies the entire byte string for validation.
|
||||
|
||||
### New Contributors
|
||||
|
||||
- [chase-roohms](https://github.com/chase-roohms)
|
||||
|
||||
## [3.4.5] - 2025-10-19
|
||||
|
||||
### Changed
|
||||
|
||||
- More flexible suffix checking to support complex archive paths.
|
||||
- Improved validation in `PageInfo.load()` to handle empty or invalid data correctly.
|
||||
|
||||
## [3.4.4] - 2025-09-21
|
||||
|
||||
### Added
|
||||
|
||||
- Added `[pillow]` extension to support `.jxl` and `.avif` images.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Files in the input archives are now sorted alphabetically.
|
||||
|
||||
## [3.4.3] - 2025-08-31
|
||||
|
||||
### Changed
|
||||
|
||||
- Bump actions/checkout from 4 to 5.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix ComicInfo XML parsing for single page comic.
|
||||
|
||||
## [3.4.2] - 2025-07-26
|
||||
|
||||
### Added
|
||||
|
||||
- Adding CI tests.
|
||||
|
||||
## [3.4.1] - 2025-07-11
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix installation instructions.
|
||||
|
||||
## [3.4.0] - 2025-07-09
|
||||
|
||||
### Added
|
||||
|
||||
- Support for PDF files.
|
||||
- Support for CBR (Comic Book RAR) files.
|
||||
|
||||
### Changed
|
||||
|
||||
- Replaced `PyMuPDF` with `pypdf` for PDF handling.
|
||||
- Updated third-party license documentation for bundled libraries.
|
||||
|
||||
### New Contributors
|
||||
|
||||
- [tssujt](https://github.com/tssujt)
|
||||
|
||||
## [3.3.7] - 2025-01-04
|
||||
|
||||
### Fixed
|
||||
|
||||
- Import error on Unix systems for the comic player.
|
||||
|
||||
## [3.3.6] - 2024-12-22
|
||||
|
||||
### Added
|
||||
|
||||
- Option to not rename the name of image files loaded into pages.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Removing deprecated datetime api for utcnow.
|
||||
|
||||
## [3.3.5] - 2024-07-22
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix `Path` import using `pathlib`.
|
||||
|
||||
## [3.3.4] - 2024-07-18
|
||||
|
||||
### Fixed
|
||||
|
||||
- Remove invalid dict key.
|
||||
- Fix invalid utc format.
|
||||
|
||||
## [3.3.3] - 2024-07-18
|
||||
|
||||
### Added
|
||||
|
||||
- Reference links for XML schema.
|
||||
- New information fields in the XML.
|
||||
- Support PDF files via `cbzplayer` command.
|
||||
|
||||
### Changed
|
||||
|
||||
- Removed MD5 display in the player (irrelevant).
|
||||
- The displayed size in the player now reflects the total size of all images.
|
||||
- Simplified the closing XML `Page` tag.
|
||||
- Sorted `Page` keys in order.
|
||||
- Updated `ComicInfo.xsd` defining the CBZ standard.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed the `.jpg` constant preventing the use of certain images.
|
||||
- Fixed memory error related to the `pack()` method cache.
|
||||
- Fixed saving pages in XML to comply with the standard.
|
||||
- Added missing mandatory keys in the XML.
|
||||
|
||||
## [3.3.2] - 2024-07-18
|
||||
|
||||
### Added
|
||||
|
||||
- Added zoom options for displaying images in the player.
|
||||
- Added scroll functionality for image display in the player, especially useful when images are zoomed.
|
||||
|
||||
### Changed
|
||||
|
||||
- Set a default standard size.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix lag when stretching player.
|
||||
- Fix XML parsing for CBZ files with a single page.
|
||||
- Fix image positioning within the player.
|
||||
|
||||
### New Contributors
|
||||
|
||||
- [gokender](https://github.com/gokender)
|
||||
|
||||
## [3.3.1] - 2024-07-15
|
||||
|
||||
### Added
|
||||
|
||||
- Added `from_pdf` method to convert `.pdf` files to `.cbz`.
|
||||
|
||||
### Changed
|
||||
|
||||
- Set a default standard size.
|
||||
- Changed a keyboard shortcut that prevented copying information.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed the icon display for Linux in the player.
|
||||
- Fixed the taskbar icon for Windows in the player.
|
||||
- Fixed the player margins.
|
||||
- Automatically detect the player size based on the smallest image.
|
||||
|
||||
### New Contributors
|
||||
|
||||
- [flolep2607](https://github.com/flolep2607)
|
||||
|
||||
## [3.3.0] - 2024-07-14
|
||||
|
||||
### Added
|
||||
|
||||
- Type value verification.
|
||||
- Load ComicInfo from a `cbz` file.
|
||||
- Built-in reader for dynamic viewing.
|
||||
- Image compatibility checking.
|
||||
- Added `save` method to directly save a page or comic.
|
||||
- Display additional file information via the player.
|
||||
|
||||
### Changed
|
||||
|
||||
- Complete code refactoring.
|
||||
- `pages` variable now public for native page manipulation in Python.
|
||||
- Optimized `pack` function with caching.
|
||||
- Library now supports loading `zip` files containing only images.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Default value definitions.
|
||||
- Corrected values written to XML.
|
||||
|
||||
### New Contributors
|
||||
|
||||
- [piskunqa](https://github.com/piskunqa)
|
||||
- [OleskiiPyskun](https://github.com/OleskiiPyskun)
|
||||
- [domenicoblanco](https://github.com/domenicoblanco)
|
||||
- [RivMt](https://github.com/RivMt)
|
||||
|
||||
## [3.2.0] - 2024-03-17
|
||||
|
||||
### Changed
|
||||
|
||||
- New code structure.
|
||||
- Deleting temporary files usage.
|
||||
- Automatic correction of variable types.
|
||||
- Simplifying constants.
|
||||
- Binary input support for pages.
|
||||
- Project `pycbzhelper` renamed to `cbz`.
|
||||
|
||||
## [3.1.2] - 2023-08-13
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed missing `Tags` key, thanks to @RivMt
|
||||
|
||||
## [3.1.1] - 2023-06-04
|
||||
|
||||
### Changed
|
||||
|
||||
- Update `README.md`.
|
||||
|
||||
## [3.1.0] - 2023-06-04
|
||||
|
||||
### Added
|
||||
|
||||
- Installation with pip.
|
||||
- Support for non-existent location.
|
||||
- Support for web loading errors of pages.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed page support.
|
||||
|
||||
### Changed
|
||||
|
||||
- New name of some variables.
|
||||
- Automatic cleanup of temporary files.
|
||||
- New location for temporary files.
|
||||
- File path now uses `pathlib`.
|
||||
|
||||
## [3.0.1] - 2023-02-06
|
||||
|
||||
### Added
|
||||
|
||||
- Initial release.
|
||||
|
||||
[4.0.0]: https://github.com/hyugogirubato/cbz/releases/tag/v4.0.0
|
||||
[3.4.5]: https://github.com/hyugogirubato/cbz/releases/tag/v3.4.5
|
||||
[3.4.4]: https://github.com/hyugogirubato/cbz/releases/tag/v3.4.4
|
||||
[3.4.3]: https://github.com/hyugogirubato/cbz/releases/tag/v3.4.3
|
||||
[3.4.2]: https://github.com/hyugogirubato/cbz/releases/tag/v3.4.2
|
||||
[3.4.1]: https://github.com/hyugogirubato/cbz/releases/tag/v3.4.1
|
||||
[3.4.0]: https://github.com/hyugogirubato/cbz/releases/tag/v3.4.0
|
||||
[3.3.7]: https://github.com/hyugogirubato/cbz/releases/tag/v3.3.7
|
||||
[3.3.6]: https://github.com/hyugogirubato/cbz/releases/tag/v3.3.6
|
||||
[3.3.5]: https://github.com/hyugogirubato/cbz/releases/tag/v3.3.5
|
||||
[3.3.4]: https://github.com/hyugogirubato/cbz/releases/tag/v3.3.4
|
||||
[3.3.3]: https://github.com/hyugogirubato/cbz/releases/tag/v3.3.3
|
||||
[3.3.2]: https://github.com/hyugogirubato/cbz/releases/tag/v3.3.2
|
||||
[3.3.1]: https://github.com/hyugogirubato/cbz/releases/tag/v3.3.1
|
||||
[3.3.0]: https://github.com/hyugogirubato/cbz/releases/tag/v3.3.0
|
||||
[3.2.0]: https://github.com/hyugogirubato/cbz/releases/tag/v3.2.0
|
||||
[3.1.2]: https://github.com/hyugogirubato/cbz/releases/tag/v3.1.2
|
||||
[3.1.1]: https://github.com/hyugogirubato/cbz/releases/tag/v3.1.1
|
||||
[3.1.0]: https://github.com/hyugogirubato/cbz/releases/tag/v3.1.0
|
||||
[3.0.1]: https://github.com/hyugogirubato/cbz/releases/tag/v3.0.1
|
||||
@@ -1,674 +1,21 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 hyugogirubato
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
@@ -1,40 +1,403 @@
|
||||
# pydvdfab
|
||||
[](https://www.gnu.org/licenses/gpl-3.0)
|
||||
[](https://github.com/hyugogirubato/pycbzhelper/releases)
|
||||

|
||||
# CBZ
|
||||
|
||||
Python library to create a cbz file with metadata.
|
||||
CBZ is a Python library designed for creating, manipulating, and viewing comic book files in CBZ, CBR, and PDF formats. It offers a straightforward interface to pack comic pages into CBZ archives, extract metadata from CBZ and CBR files, and display comics using a built-in player.
|
||||
|
||||
# Usage
|
||||
## Features
|
||||
|
||||
### Basic Usage
|
||||
- Seamless installation via [pip](#installation)
|
||||
- Pack images into CBZ format for comics and manga
|
||||
- Extract and manage metadata: title, series, format, and more
|
||||
- Handle comic pages with attributes like type, dimensions, and bookmarks
|
||||
- Unpack CBZ and CBR files to retrieve comic information, or extract images from PDF files
|
||||
- Built-in player for viewing CBZ, CBR, and PDF comics
|
||||
- Sequence protocol: iterate, index, and slice comic pages directly
|
||||
- Dataclass-based models with automatic XML mapping and strict type validation
|
||||
- Image support: JPEG, PNG, GIF, BMP, TIFF, WebP, JPEG XL, AVIF
|
||||
- Fully open-source! Pull requests welcome
|
||||
|
||||
```python
|
||||
>>> import os
|
||||
>>> from pycbzhelper import Helper
|
||||
>>> metadata = {
|
||||
>>> "Title": "T1 - Arrête de me chauffer, Nagatoro",
|
||||
>>> "Series": "Arrête de me chauffer, Nagatoro",
|
||||
>>> "Number": "1",
|
||||
>>> "Count": 8,
|
||||
>>> "Volume": 1
|
||||
>>> ...
|
||||
>>> }
|
||||
>>> ...
|
||||
>>> helper = Helper(metadata)
|
||||
>>> helper.save_cbz(
|
||||
... path=os.path.join("eBooks", "Arrête de me chauffer, Nagatoro"),
|
||||
... file="T1 - Arrête de me chauffer, Nagatoro",
|
||||
... clear=False,
|
||||
... replace=True
|
||||
... )
|
||||
## Installation
|
||||
|
||||
Install CBZ from PyPI using pip:
|
||||
|
||||
```shell
|
||||
pip install cbz
|
||||
```
|
||||
|
||||
# Installation
|
||||
With AVIF and JPEG XL support:
|
||||
|
||||
To install, you can either clone the repository and run `python setup.py install`
|
||||
```shell
|
||||
pip install cbz[pillow]
|
||||
```
|
||||
|
||||
## About
|
||||
- Graphical metadata editing software [here](https://github.com/comictagger/comictagger)
|
||||
- Standard ComicInfo file structure information [here](https://github.com/Kussie/ComicInfoStandard)
|
||||
- New version of ComicInfo file structure [here](https://github.com/anansi-project/comicinfo)
|
||||
## 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 import ComicInfo, PageInfo, PageType, Format, YesNo, Manga, AgeRating
|
||||
|
||||
if __name__ == "__main__":
|
||||
paths = sorted(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 with metadata
|
||||
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.RATING_PENDING,
|
||||
)
|
||||
|
||||
# Display the comic in the built-in reader
|
||||
comic.show()
|
||||
|
||||
# Save directly as a CBZ file
|
||||
comic.save("your_comic.cbz")
|
||||
|
||||
# Or pack to bytes for custom handling
|
||||
cbz_content = comic.pack()
|
||||
Path("your_comic.cbz").write_bytes(cbz_content)
|
||||
```
|
||||
|
||||
## Player
|
||||
|
||||
CBZ includes a command-line player for viewing comic book files in multiple formats. Simply run `cbzplayer <file>` to launch the player with the specified comic book file.
|
||||
|
||||
### Supported Formats
|
||||
|
||||
- **CBZ** (Comic Book ZIP) - Standard ZIP archives containing images and metadata
|
||||
- **CBR** (Comic Book RAR) - RAR archives containing images and metadata
|
||||
- **PDF** - Portable Document Format files with embedded images (images only, no metadata)
|
||||
|
||||
### Usage
|
||||
|
||||
```shell
|
||||
usage: cbzplayer [-h] <file>
|
||||
|
||||
CBZ/CBR/PDF comic reader
|
||||
|
||||
positional arguments:
|
||||
<file> Path to the CBZ, CBR or PDF comic book file.
|
||||
|
||||
options:
|
||||
-h, --help show this help message and exit
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
```shell
|
||||
# View a CBZ file
|
||||
cbzplayer my_comic.cbz
|
||||
|
||||
# View a CBR file
|
||||
cbzplayer my_comic.cbr
|
||||
|
||||
# View a PDF file
|
||||
cbzplayer my_comic.pdf
|
||||
```
|
||||
|
||||
### Keyboard Shortcuts
|
||||
|
||||
| Shortcut | Action |
|
||||
|---------------------|-------------------|
|
||||
| Left / Right arrows | Navigate pages |
|
||||
| + / - | Zoom in / out |
|
||||
| Ctrl+Q | Quit |
|
||||
| Mouse wheel | Vertical scroll |
|
||||
| Shift+Mouse wheel | Horizontal scroll |
|
||||
| Ctrl+Mouse wheel | Zoom |
|
||||
|
||||
### Requirements for CBR Support
|
||||
|
||||
CBR file support requires:
|
||||
|
||||
- The `rarfile` Python package (automatically installed with CBZ)
|
||||
- An external RAR extraction tool such as:
|
||||
- `unrar` (recommended) - Available in most package managers
|
||||
- `rar` - Commercial RAR archiver
|
||||
- `7zip` - Free alternative with RAR support
|
||||
|
||||
For installation instructions and compatibility details, see the [rarfile documentation](https://github.com/markokr/rarfile).
|
||||
|
||||
## 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 import ComicInfo, PageInfo, PageType, Format, YesNo, Manga, AgeRating
|
||||
|
||||
pages = [
|
||||
PageInfo.load(path="page1.jpg", type=PageType.FRONT_COVER),
|
||||
PageInfo.load(path="page2.jpg", type=PageType.STORY),
|
||||
PageInfo.load(path="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.RATING_PENDING,
|
||||
)
|
||||
```
|
||||
|
||||
You can also create pages directly from bytes or base64-encoded data:
|
||||
|
||||
```python
|
||||
page = PageInfo.loads(data=image_bytes, name="page.jpg", type=PageType.STORY)
|
||||
```
|
||||
|
||||
### Sequence Protocol
|
||||
|
||||
`ComicInfo` implements the full sequence protocol, so you can interact with pages directly:
|
||||
|
||||
```python
|
||||
len(comic) # Number of pages
|
||||
comic[0] # First page
|
||||
comic[-1] # Last page
|
||||
comic[1:3] # Slice of pages
|
||||
for page in comic: # Iteration
|
||||
print(page.image_width, page.image_height)
|
||||
page in comic # Containment check
|
||||
```
|
||||
|
||||
### Extracting Metadata
|
||||
|
||||
Retrieve comic information as a dictionary using `get_info()`:
|
||||
|
||||
```python
|
||||
info = comic.get_info()
|
||||
print(info)
|
||||
```
|
||||
|
||||
### Packing and Saving
|
||||
|
||||
Pack the comic into CBZ format as bytes:
|
||||
|
||||
```python
|
||||
cbz_content = comic.pack()
|
||||
```
|
||||
|
||||
Or save directly to disk (more memory-efficient for large archives):
|
||||
|
||||
```python
|
||||
comic.save("output.cbz")
|
||||
```
|
||||
|
||||
### Loading from Different Formats
|
||||
|
||||
Load a comic from an existing CBZ file (with metadata):
|
||||
|
||||
```python
|
||||
comic = ComicInfo.from_cbz("your_comic.cbz")
|
||||
```
|
||||
|
||||
Load a comic from an existing CBR file (with metadata):
|
||||
|
||||
```python
|
||||
comic = ComicInfo.from_cbr("your_comic.cbr")
|
||||
```
|
||||
|
||||
Load a comic from a PDF file (images only, no metadata):
|
||||
|
||||
```python
|
||||
comic = ComicInfo.from_pdf("your_comic.pdf")
|
||||
```
|
||||
|
||||
**Notes:**
|
||||
|
||||
- CBR support requires an external RAR extraction tool. For detailed compatibility information and advanced configuration, see the [rarfile documentation](https://github.com/markokr/rarfile).
|
||||
- PDF files only provide image content; comic metadata (title, series, etc.) is not available from PDF files.
|
||||
|
||||
### Page Properties
|
||||
|
||||
Each `PageInfo` object exposes the following properties, automatically extracted from the image content:
|
||||
|
||||
```python
|
||||
page = comic[0]
|
||||
|
||||
page.content # bytes - raw image data
|
||||
page.image_width # int - width in pixels
|
||||
page.image_height # int - height in pixels
|
||||
page.image_size # int - file size in bytes
|
||||
page.suffix # str - file extension (.jpg, .png, etc.)
|
||||
page.name # str - original file name
|
||||
page.type # PageType - page type (FrontCover, Story, etc.)
|
||||
page.bookmark # str - bookmark / chapter name
|
||||
page.double # bool - double page spread
|
||||
```
|
||||
|
||||
### Metadata Fields
|
||||
|
||||
All [ComicInfo.xml](docs/RFC-CBZ.md) v2.1 metadata fields are supported as dataclass attributes:
|
||||
|
||||
| Attribute | Type | Default | Description |
|
||||
|--------------------------|--------------------|-----------|------------------------------------------|
|
||||
| `title` | `str` | `""` | Issue title |
|
||||
| `series` | `str` | `""` | Series name |
|
||||
| `number` | `Optional[int]` | `None` | Issue number |
|
||||
| `count` | `Optional[int]` | `None` | Total number of issues |
|
||||
| `volume` | `Optional[int]` | `None` | Volume number |
|
||||
| `year` | `Optional[int]` | `None` | Publication year |
|
||||
| `month` | `Optional[int]` | `None` | Publication month |
|
||||
| `day` | `Optional[int]` | `None` | Publication day |
|
||||
| `writer` | `str` | `""` | Writer(s), comma-separated |
|
||||
| `penciller` | `str` | `""` | Pencil artist(s) |
|
||||
| `inker` | `str` | `""` | Inker(s) |
|
||||
| `colorist` | `str` | `""` | Colorist(s) |
|
||||
| `letterer` | `str` | `""` | Letterer(s) |
|
||||
| `cover_artist` | `str` | `""` | Cover artist(s) |
|
||||
| `editor` | `str` | `""` | Editor(s) |
|
||||
| `translator` | `str` | `""` | Translator(s) |
|
||||
| `publisher` | `str` | `""` | Publisher |
|
||||
| `imprint` | `str` | `""` | Publisher imprint |
|
||||
| `genre` | `str` | `""` | Genre(s), comma-separated |
|
||||
| `tags` | `str` | `""` | Tags, comma-separated |
|
||||
| `web` | `str` | `""` | Web URL |
|
||||
| `language_iso` | `LanguageISO` | `""` | ISO language code (e.g., `"en"`, `"fr"`) |
|
||||
| `format` | `Format` | `UNKNOWN` | Publication format |
|
||||
| `black_white` | `YesNo` | `UNKNOWN` | Black and white |
|
||||
| `manga` | `Manga` | `UNKNOWN` | Manga / reading direction |
|
||||
| `age_rating` | `AgeRating` | `UNKNOWN` | Content age rating |
|
||||
| `community_rating` | `Optional[Rating]` | `None` | Community rating (0.0-5.0) |
|
||||
| `summary` | `str` | `""` | Synopsis / description |
|
||||
| `characters` | `str` | `""` | Character names, comma-separated |
|
||||
| `teams` | `str` | `""` | Team names, comma-separated |
|
||||
| `locations` | `str` | `""` | Locations, comma-separated |
|
||||
| `story_arc` | `str` | `""` | Story arc name |
|
||||
| `story_arc_number` | `Optional[int]` | `None` | Position in story arc |
|
||||
| `main_character_or_team` | `str` | `""` | Primary character or team |
|
||||
| `scan_information` | `str` | `""` | Scan / digitization notes |
|
||||
| `ean` | `str` | `""` | EAN / ISBN |
|
||||
| `book_price` | `str` | `""` | Cover price |
|
||||
|
||||
### Enumerations
|
||||
|
||||
```python
|
||||
from cbz import PageType, Format, YesNo, Manga, AgeRating
|
||||
|
||||
# Page types
|
||||
PageType.FRONT_COVER # Front cover
|
||||
PageType.STORY # Story page (default)
|
||||
PageType.BACK_COVER # Back cover
|
||||
PageType.INNER_COVER # Inner cover / dust jacket
|
||||
PageType.ADVERTISEMENT # Advertisement
|
||||
PageType.EDITORIAL # Editorial / credits
|
||||
PageType.LETTERS # Letters page
|
||||
PageType.PREVIEW # Preview of upcoming issues
|
||||
PageType.ROUNDUP # Recap / summary
|
||||
PageType.OTHER # Other
|
||||
PageType.DELETED # Marked for deletion
|
||||
|
||||
# Publication formats
|
||||
Format.SERIES # Regular series
|
||||
Format.GRAPHIC_NOVEL # Graphic novel
|
||||
Format.WEB_COMIC # Webcomic
|
||||
Format.ONE_SHOT # One-shot
|
||||
Format.TRADE_PAPERBACK # Trade paperback
|
||||
Format.ANNUAL # Annual
|
||||
Format.ANTHOLOGY # Anthology
|
||||
Format.LIMITED_SERIES # Limited series
|
||||
Format.MAGAZINE # Magazine
|
||||
# ... and more
|
||||
|
||||
# Reading direction
|
||||
Manga.UNKNOWN # Not specified
|
||||
Manga.NO # Western (left to right)
|
||||
Manga.YES # Manga
|
||||
Manga.YES_AND_RIGHT_TO_LEFT # Manga (right to left)
|
||||
|
||||
# Age ratings
|
||||
AgeRating.UNKNOWN # Not rated
|
||||
AgeRating.EVERYONE # All ages
|
||||
AgeRating.TEEN # Teens
|
||||
AgeRating.MATURE_17_PLUS # Mature 17+
|
||||
AgeRating.RATING_PENDING # Rating pending
|
||||
# ... and more
|
||||
```
|
||||
|
||||
### Error Handling
|
||||
|
||||
The library provides a hierarchy of specific exceptions:
|
||||
|
||||
```python
|
||||
from cbz import CBZError, InvalidImageError, EmptyArchiveError, InvalidMetadataError
|
||||
|
||||
try:
|
||||
comic = ComicInfo.from_cbz("corrupted.cbz")
|
||||
except InvalidMetadataError:
|
||||
print("ComicInfo.xml is invalid or corrupted")
|
||||
except EmptyArchiveError:
|
||||
print("No valid images found in the archive")
|
||||
except InvalidImageError:
|
||||
print("An image in the archive could not be read")
|
||||
except CBZError:
|
||||
print("General CBZ error")
|
||||
```
|
||||
|
||||
## Format Specification
|
||||
|
||||
A complete RFC specification of the CBZ format is available in [`docs/RFC-CBZ.md`](docs/RFC-CBZ.md).
|
||||
|
||||
The ComicInfo.xml XSD schemas (v1.0, v2.0, v2.1) are in [`docs/schema/`](docs/schema/).
|
||||
|
||||
## Changelog
|
||||
|
||||
See [`CHANGELOG.md`](CHANGELOG.md) for the full version history, including migration notes for v4.0.
|
||||
|
||||
## 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/tssujt"><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/17313425?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="tssujt"/></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>
|
||||
<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/chase-roohms"><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/131704514?v=4&h=25&w=25&fit=cover&mask=circle&maxage=7d" alt="chase-roohms"/></a>
|
||||
|
||||
## Licensing
|
||||
|
||||
This software is licensed under the terms of [MIT License](LICENSE). You can find a copy of the license in the LICENSE file in the root folder.
|
||||
|
||||
### Third-Party Licenses
|
||||
|
||||
This project uses the following third-party libraries:
|
||||
|
||||
- **[langcodes](https://pypi.org/project/langcodes/)** - MIT License
|
||||
- **[Pillow](https://pypi.org/project/Pillow/)** - HPND License
|
||||
- **[pillow-avif-plugin](https://pypi.org/project/pillow-avif-plugin/)** - MIT License
|
||||
- **[pillow-jxl-plugin](https://pypi.org/project/pillow-jxl-plugin/)** - MIT License
|
||||
- **[pypdf](https://pypi.org/project/pypdf/)** - BSD License
|
||||
- **[rarfile](https://pypi.org/project/rarfile/)** - ISC License
|
||||
- **[xmltodict](https://pypi.org/project/xmltodict/)** - MIT License
|
||||
|
||||
---
|
||||
|
||||
© hyugogirubato
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
"""
|
||||
CBZ - Python library for digital comic book management.
|
||||
|
||||
Supports creating, manipulating and viewing CBZ (Comic Book ZIP),
|
||||
CBR (Comic Book RAR) and PDF files.
|
||||
"""
|
||||
|
||||
from cbz.comic import ComicInfo
|
||||
from cbz.page import PageInfo
|
||||
from cbz.constants import (
|
||||
AgeRating,
|
||||
Format,
|
||||
LanguageISO,
|
||||
Manga,
|
||||
PageType,
|
||||
Rating,
|
||||
YesNo
|
||||
)
|
||||
from cbz.exceptions import (
|
||||
CBZError,
|
||||
EmptyArchiveError,
|
||||
InvalidImageError,
|
||||
InvalidMetadataError,
|
||||
UnsupportedFormatError
|
||||
)
|
||||
|
||||
__version__ = "4.0.0"
|
||||
__all__ = [
|
||||
"ComicInfo",
|
||||
"PageInfo",
|
||||
"AgeRating",
|
||||
"Format",
|
||||
"LanguageISO",
|
||||
"Manga",
|
||||
"PageType",
|
||||
"Rating",
|
||||
"YesNo",
|
||||
"CBZError",
|
||||
"EmptyArchiveError",
|
||||
"InvalidImageError",
|
||||
"InvalidMetadataError",
|
||||
"UnsupportedFormatError"
|
||||
]
|
||||
|
||||
# Load optional Pillow plugins (AVIF, JPEG XL)
|
||||
for _plugin in ("pillow_avif", "pillow_jxl"):
|
||||
try:
|
||||
__import__(_plugin)
|
||||
except ImportError:
|
||||
pass
|
||||
@@ -0,0 +1,47 @@
|
||||
"""CLI entry point for the CBZ comic reader."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from cbz.comic import ComicInfo
|
||||
from cbz.exceptions import CBZError
|
||||
|
||||
|
||||
def main() -> None:
|
||||
"""Launch the comic reader with the specified file."""
|
||||
parser = argparse.ArgumentParser(
|
||||
description="CBZ/CBR/PDF comic reader"
|
||||
)
|
||||
parser.add_argument(
|
||||
"comic_path",
|
||||
type=Path,
|
||||
metavar="<file>",
|
||||
help="Path to the CBZ, CBR or PDF comic book file."
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
path: Path = args.comic_path
|
||||
if not path.is_file():
|
||||
print(f"Error: file '{path}' does not exist.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
suffix = path.suffix.lower()
|
||||
if suffix == ".pdf":
|
||||
comic = ComicInfo.from_pdf(path)
|
||||
elif suffix == ".cbr":
|
||||
comic = ComicInfo.from_cbr(path)
|
||||
else:
|
||||
comic = ComicInfo.from_cbz(path)
|
||||
|
||||
comic.show()
|
||||
except CBZError as e:
|
||||
print(f"Error: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
After Width: | Height: | Size: 124 KiB |
@@ -0,0 +1,373 @@
|
||||
"""
|
||||
Main CBZ comic management module.
|
||||
|
||||
Provides the ComicInfo class to create, load, manipulate and
|
||||
save comics in CBZ, CBR and PDF formats.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import functools
|
||||
import logging
|
||||
import typing
|
||||
import zipfile
|
||||
from dataclasses import dataclass, field, fields
|
||||
from datetime import datetime, timezone
|
||||
from enum import Enum
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from typing import Iterator, List, Union
|
||||
|
||||
import rarfile
|
||||
import xmltodict
|
||||
from pypdf import PdfReader
|
||||
|
||||
from cbz.constants import IMAGE_FORMATS, XML_NAME
|
||||
from cbz.exceptions import EmptyArchiveError, InvalidMetadataError
|
||||
from cbz.models import ComicModel, PageModel
|
||||
from cbz.page import PageInfo
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@functools.lru_cache(maxsize=None)
|
||||
def _resolve_type_hints(model_cls: type) -> dict:
|
||||
"""Resolve dataclass type annotations to actual types.
|
||||
|
||||
Handles optional types (Optional[X] / Union[X, None]) by
|
||||
extracting the base type.
|
||||
"""
|
||||
hints = typing.get_type_hints(model_cls)
|
||||
resolved = {}
|
||||
for name, hint in hints.items():
|
||||
origin = getattr(hint, "__origin__", None)
|
||||
if origin is Union:
|
||||
# Optional[int] == Union[int, None] -> extract the non-None type
|
||||
args = [a for a in hint.__args__ if a is not type(None)]
|
||||
resolved[name] = args[0] if args else str
|
||||
else:
|
||||
resolved[name] = hint
|
||||
return resolved
|
||||
|
||||
|
||||
def _extract_fields(items: dict, model_cls: type) -> dict:
|
||||
"""Extract and convert XML fields to Python model fields.
|
||||
|
||||
Iterates over the dataclass fields of model_cls, looks up the
|
||||
XML correspondence in items, and converts values to the correct type.
|
||||
|
||||
Args:
|
||||
items: Dictionary of parsed XML elements/attributes.
|
||||
model_cls: Dataclass class (ComicModel or PageModel).
|
||||
|
||||
Returns:
|
||||
Dictionary {python_name: converted_value}.
|
||||
"""
|
||||
type_hints = _resolve_type_hints(model_cls)
|
||||
result = {}
|
||||
for f in fields(model_cls):
|
||||
xml_name = f.metadata.get("xml_name")
|
||||
if xml_name and xml_name in items:
|
||||
raw = items[xml_name]
|
||||
try:
|
||||
field_type = type_hints.get(f.name, str)
|
||||
result[f.name] = field_type(raw)
|
||||
except (ValueError, KeyError):
|
||||
logger.warning("Unable to convert field %s=%r", xml_name, raw)
|
||||
return result
|
||||
|
||||
|
||||
def _serialize_fields(obj: object, model_cls: type) -> dict:
|
||||
"""Serialize object fields to an XML dictionary.
|
||||
|
||||
Ignores fields with default/empty values (empty strings, None, UNKNOWN).
|
||||
|
||||
Args:
|
||||
obj: Model instance.
|
||||
model_cls: Dataclass class of the model.
|
||||
|
||||
Returns:
|
||||
Dictionary {xml_name: value} ready for XML serialization.
|
||||
"""
|
||||
result = {}
|
||||
for f in fields(model_cls):
|
||||
xml_name = f.metadata.get("xml_name")
|
||||
if not xml_name:
|
||||
continue
|
||||
|
||||
value = getattr(obj, f.name)
|
||||
|
||||
# Skip default / empty values
|
||||
if value is None:
|
||||
continue
|
||||
if isinstance(value, str) and not value:
|
||||
continue
|
||||
if isinstance(value, Enum) and value == f.default:
|
||||
continue
|
||||
|
||||
# Convert enums to their string value
|
||||
if isinstance(value, Enum):
|
||||
result[xml_name] = value.value
|
||||
else:
|
||||
result[xml_name] = value
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@dataclass
|
||||
class ComicInfo(ComicModel):
|
||||
"""Represents a complete comic with its metadata and pages.
|
||||
|
||||
Supports creation from images, loading from CBZ/CBR/PDF archives,
|
||||
serialization to CBZ and display via the built-in viewer.
|
||||
|
||||
Implements the sequence protocol for page access:
|
||||
- len(comic) returns the number of pages
|
||||
- comic[i] returns page i
|
||||
- for page in comic: iterates over pages
|
||||
|
||||
Attributes:
|
||||
pages: List of comic pages.
|
||||
"""
|
||||
|
||||
pages: List[PageInfo] = field(default_factory=list)
|
||||
|
||||
# -- Alternative constructors (factory methods) --
|
||||
|
||||
@classmethod
|
||||
def from_pages(cls, pages: List[PageInfo], **kwargs) -> ComicInfo:
|
||||
"""Create a ComicInfo from a list of pages and metadata.
|
||||
|
||||
Args:
|
||||
pages: List of PageInfo objects.
|
||||
**kwargs: Comic metadata (title, series, etc.).
|
||||
|
||||
Returns:
|
||||
New ComicInfo instance.
|
||||
"""
|
||||
return cls(pages=pages, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def _from_archive(cls, path: Union[Path, str], opener: type) -> ComicInfo:
|
||||
"""Load a comic from an archive file (CBZ or CBR).
|
||||
|
||||
Args:
|
||||
path: Path to the archive file.
|
||||
opener: Archive class (zipfile.ZipFile or rarfile.RarFile).
|
||||
|
||||
Returns:
|
||||
ComicInfo instance with pages and metadata.
|
||||
"""
|
||||
with opener(Path(path), "r") as archive:
|
||||
return cls._process_archive(archive)
|
||||
|
||||
@classmethod
|
||||
def from_cbz(cls, path: Union[Path, str]) -> ComicInfo:
|
||||
"""Load a comic from a CBZ (ZIP) file.
|
||||
|
||||
Args:
|
||||
path: Path to the .cbz file.
|
||||
|
||||
Returns:
|
||||
ComicInfo instance with pages and metadata.
|
||||
|
||||
Raises:
|
||||
EmptyArchiveError: If the archive contains no images.
|
||||
"""
|
||||
return cls._from_archive(path, zipfile.ZipFile)
|
||||
|
||||
@classmethod
|
||||
def from_cbr(cls, path: Union[Path, str]) -> ComicInfo:
|
||||
"""Load a comic from a CBR (RAR) file.
|
||||
|
||||
Args:
|
||||
path: Path to the .cbr file.
|
||||
|
||||
Returns:
|
||||
ComicInfo instance with pages and metadata.
|
||||
|
||||
Raises:
|
||||
EmptyArchiveError: If the archive contains no images.
|
||||
"""
|
||||
return cls._from_archive(path, rarfile.RarFile)
|
||||
|
||||
@classmethod
|
||||
def from_pdf(cls, path: Union[Path, str]) -> ComicInfo:
|
||||
"""Load a comic from a PDF file (image extraction).
|
||||
|
||||
Only images are extracted; PDF metadata is not converted
|
||||
to ComicInfo metadata.
|
||||
|
||||
Args:
|
||||
path: Path to the .pdf file.
|
||||
|
||||
Returns:
|
||||
ComicInfo instance with extracted images.
|
||||
|
||||
Raises:
|
||||
EmptyArchiveError: If the PDF contains no images.
|
||||
"""
|
||||
pages: List[PageInfo] = []
|
||||
reader = PdfReader(Path(path))
|
||||
for pdf_page in reader.pages:
|
||||
for image in pdf_page.images:
|
||||
pages.append(PageInfo.loads(data=image.data))
|
||||
|
||||
if not pages:
|
||||
raise EmptyArchiveError("No valid images found in PDF file")
|
||||
return cls.from_pages(pages=pages)
|
||||
|
||||
# -- Sequence protocol --
|
||||
|
||||
def __len__(self) -> int:
|
||||
"""Number of pages in the comic."""
|
||||
return len(self.pages)
|
||||
|
||||
def __getitem__(self, index):
|
||||
"""Access a page by index or slice."""
|
||||
return self.pages[index]
|
||||
|
||||
def __iter__(self) -> Iterator[PageInfo]:
|
||||
"""Iterate over comic pages."""
|
||||
return iter(self.pages)
|
||||
|
||||
def __contains__(self, page: PageInfo) -> bool:
|
||||
"""Check if a page belongs to the comic."""
|
||||
return page in self.pages
|
||||
|
||||
# -- Internal methods --
|
||||
|
||||
@classmethod
|
||||
def _process_archive(cls, archive) -> ComicInfo:
|
||||
"""Common processing for CBZ and CBR archives.
|
||||
|
||||
Extracts the ComicInfo.xml file if present, then loads
|
||||
images sorted alphabetically.
|
||||
|
||||
Args:
|
||||
archive: Open archive object (ZipFile or RarFile).
|
||||
|
||||
Returns:
|
||||
ComicInfo instance.
|
||||
"""
|
||||
pages: List[PageInfo] = []
|
||||
names = sorted(archive.namelist())
|
||||
comic_data: dict = {}
|
||||
|
||||
# Extract XML metadata
|
||||
if XML_NAME in names:
|
||||
with archive.open(XML_NAME, "r") as f:
|
||||
try:
|
||||
comic_data = xmltodict.parse(
|
||||
f.read(), force_list=("Page",)
|
||||
).get("ComicInfo", {})
|
||||
except Exception as e:
|
||||
raise InvalidMetadataError(f"XML parsing error: {e}") from e
|
||||
names.remove(XML_NAME)
|
||||
|
||||
# Extract comic fields
|
||||
comic_kwargs = _extract_fields(comic_data, ComicModel)
|
||||
|
||||
# Extract page information
|
||||
pages_info = comic_data.get("Pages", {}).get("Page", [])
|
||||
|
||||
for i, name in enumerate(names):
|
||||
suffix = Path(name).suffix
|
||||
if suffix.lower() not in IMAGE_FORMATS:
|
||||
logger.warning("Skipping unsupported file: %r", name)
|
||||
continue
|
||||
|
||||
with archive.open(name, "r") as f:
|
||||
page_kwargs: dict = {}
|
||||
if i < len(pages_info):
|
||||
page_kwargs = _extract_fields(pages_info[i], PageModel)
|
||||
page_kwargs["name"] = Path(name).name
|
||||
pages.append(PageInfo.loads(data=f.read(), **page_kwargs))
|
||||
|
||||
return cls.from_pages(pages=pages, **comic_kwargs)
|
||||
|
||||
def get_info(self) -> dict:
|
||||
"""Return comic metadata as an XML-ready dictionary.
|
||||
|
||||
Generates a dictionary ready for XML serialization via xmltodict,
|
||||
including comic metadata, file information and page details.
|
||||
|
||||
Returns:
|
||||
Structured dictionary for XML serialization.
|
||||
"""
|
||||
comic_info = _serialize_fields(self, ComicModel)
|
||||
|
||||
# Build page information
|
||||
comic_pages = []
|
||||
for i, page in enumerate(self.pages):
|
||||
page_info = _serialize_fields(page, PageModel)
|
||||
page_info["@Image"] = i
|
||||
comic_pages.append(dict(sorted(page_info.items())))
|
||||
|
||||
# File metadata
|
||||
utcnow = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + "Z"
|
||||
comic_info.update({
|
||||
"@xmlns:xsd": "http://www.w3.org/2001/XMLSchema",
|
||||
"@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
|
||||
"FileSize": comic_info.get("FileSize", sum(p.image_size for p in self.pages)),
|
||||
"FileCreationTime": comic_info.get("FileCreationTime", utcnow),
|
||||
"FileModifiedTime": comic_info.get("FileModifiedTime", utcnow),
|
||||
"PageCount": len(self.pages),
|
||||
"Pages": {"Page": comic_pages},
|
||||
})
|
||||
return comic_info
|
||||
|
||||
def pack(self, rename: bool = True, compression: int = zipfile.ZIP_STORED) -> bytes:
|
||||
"""Pack the comic into CBZ format (ZIP archive).
|
||||
|
||||
Args:
|
||||
rename: If True, rename pages to sequential format (page-001.jpg).
|
||||
compression: ZIP compression method (default: ZIP_STORED).
|
||||
|
||||
Returns:
|
||||
Binary data of the CBZ file.
|
||||
"""
|
||||
buf = BytesIO()
|
||||
with zipfile.ZipFile(buf, "w", compression) as zf:
|
||||
# Write XML metadata
|
||||
xml_content = xmltodict.unparse({"ComicInfo": self.get_info()}, pretty=True)
|
||||
zf.writestr(XML_NAME, xml_content.replace("></Page>", " />").encode("utf-8"))
|
||||
|
||||
# Write pages
|
||||
for i, page in enumerate(self.pages):
|
||||
name = page.name
|
||||
if not name or rename:
|
||||
name = f"page-{i + 1:03d}{page.suffix}"
|
||||
zf.writestr(name, page.content)
|
||||
|
||||
data = buf.getvalue()
|
||||
buf.close()
|
||||
return data
|
||||
|
||||
def show(self) -> None:
|
||||
"""Display the comic in the built-in graphical viewer."""
|
||||
from cbz.player import Player
|
||||
player = Player(self)
|
||||
player.run()
|
||||
|
||||
def save(self, path: Union[Path, str], rename: bool = True,
|
||||
compression: int = zipfile.ZIP_STORED) -> None:
|
||||
"""Save the comic as a CBZ file directly to disk.
|
||||
|
||||
More memory-efficient than pack() for large comics since it
|
||||
writes directly to the file without an intermediate buffer.
|
||||
|
||||
Args:
|
||||
path: Destination file path for the .cbz file.
|
||||
rename: If True, rename pages to sequential format (page-001.jpg).
|
||||
compression: ZIP compression method (default: ZIP_STORED).
|
||||
"""
|
||||
with zipfile.ZipFile(Path(path), "w", compression) as zf:
|
||||
xml_content = xmltodict.unparse({"ComicInfo": self.get_info()}, pretty=True)
|
||||
zf.writestr(XML_NAME, xml_content.replace("></Page>", " />").encode("utf-8"))
|
||||
|
||||
for i, page in enumerate(self.pages):
|
||||
name = page.name
|
||||
if not name or rename:
|
||||
name = f"page-{i + 1:03d}{page.suffix}"
|
||||
zf.writestr(name, page.content)
|
||||
@@ -0,0 +1,143 @@
|
||||
"""
|
||||
Constants and types for the CBZ/ComicInfo format.
|
||||
|
||||
Defines enumerations, supported types and field mappings
|
||||
conforming to the ComicInfo.xml v2.1 schema.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from enum import Enum
|
||||
from typing import Union
|
||||
|
||||
from langcodes import Language
|
||||
|
||||
|
||||
class StrEnum(str, Enum):
|
||||
"""Backport of StrEnum for Python < 3.11."""
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.value
|
||||
|
||||
|
||||
# Name of the XML metadata file inside the CBZ archive
|
||||
XML_NAME = "ComicInfo.xml"
|
||||
|
||||
# Supported image formats in CBZ archives
|
||||
IMAGE_FORMATS: frozenset = frozenset({
|
||||
".jpeg", ".jpg", ".png", ".gif", ".bmp",
|
||||
".tiff", ".tif", ".webp", ".jxl", ".avif"
|
||||
})
|
||||
|
||||
|
||||
class YesNo(StrEnum):
|
||||
"""Ternary boolean: Unknown / No / Yes."""
|
||||
UNKNOWN = "Unknown"
|
||||
NO = "No"
|
||||
YES = "Yes"
|
||||
|
||||
|
||||
class Manga(StrEnum):
|
||||
"""Comic reading direction."""
|
||||
UNKNOWN = "Unknown"
|
||||
NO = "No"
|
||||
YES = "Yes"
|
||||
YES_AND_RIGHT_TO_LEFT = "YesAndRightToLeft"
|
||||
|
||||
|
||||
class PageType(StrEnum):
|
||||
"""Page type within the archive."""
|
||||
FRONT_COVER = "FrontCover"
|
||||
INNER_COVER = "InnerCover"
|
||||
ROUNDUP = "Roundup"
|
||||
STORY = "Story"
|
||||
ADVERTISEMENT = "Advertisement"
|
||||
EDITORIAL = "Editorial"
|
||||
LETTERS = "Letters"
|
||||
PREVIEW = "Preview"
|
||||
BACK_COVER = "BackCover"
|
||||
OTHER = "Other"
|
||||
DELETED = "Deleted"
|
||||
|
||||
|
||||
class AgeRating(StrEnum):
|
||||
"""Content age rating classification."""
|
||||
UNKNOWN = "Unknown"
|
||||
ADULTS_ONLY_18_PLUS = "Adults Only 18+"
|
||||
EARLY_CHILDHOOD = "Early Childhood"
|
||||
EVERYONE = "Everyone"
|
||||
EVERYONE_10_PLUS = "Everyone 10+"
|
||||
G = "G"
|
||||
KIDS_TO_ADULTS = "Kids to Adults"
|
||||
M = "M"
|
||||
MA15_PLUS = "MA15+"
|
||||
MATURE_17_PLUS = "Mature 17+"
|
||||
PG = "PG"
|
||||
R18_PLUS = "R18+"
|
||||
RATING_PENDING = "Rating Pending"
|
||||
TEEN = "Teen"
|
||||
X18_PLUS = "X18+"
|
||||
|
||||
|
||||
class Format(StrEnum):
|
||||
"""Comic publication format."""
|
||||
UNKNOWN = "Unknown"
|
||||
ANNOTATION = "Annotation"
|
||||
ANNUAL = "Annual"
|
||||
ANTHOLOGY = "Anthology"
|
||||
BLACK_AND_WHITE = "Black & White"
|
||||
BOX_SET = "Box-Set"
|
||||
CROSSOVER = "Crossover"
|
||||
DIRECTORS_CUT = "Director's Cut"
|
||||
EPILOGUE = "Epilogue"
|
||||
EVENT = "Event"
|
||||
FCBD = "FCBD"
|
||||
FLYER = "Flyer"
|
||||
GIANT_SIZE = "Giant-Size"
|
||||
GRAPHIC_NOVEL = "Graphic Novel"
|
||||
HARDCOVER = "Hard-Cover"
|
||||
KING_SIZE = "King-Size"
|
||||
LIMITED_SERIES = "Limited Series"
|
||||
MAGAZINE = "Magazine"
|
||||
NSFW = "NSFW"
|
||||
ONE_SHOT = "One-Shot"
|
||||
POINT_ONE = "Point 1"
|
||||
PREVIEW = "Preview"
|
||||
PROLOGUE = "Prologue"
|
||||
REFERENCE = "Reference"
|
||||
REVIEW = "Review"
|
||||
REVIEWED = "Reviewed"
|
||||
SCANLATION = "Scanlation"
|
||||
SCRIPT = "Script"
|
||||
SERIES = "Series"
|
||||
SKETCH = "Sketch"
|
||||
SPECIAL = "Special"
|
||||
TRADE_PAPERBACK = "Trade Paper Back"
|
||||
WEB_COMIC = "Web Comic"
|
||||
YEAR_ONE = "Year One"
|
||||
|
||||
|
||||
class Rating(float):
|
||||
"""Community rating between 0.0 and 5.0 (None if unset)."""
|
||||
|
||||
def __new__(cls, value: Union[int, float] = 0.0) -> Rating:
|
||||
val = float(value)
|
||||
if not (0.0 <= val <= 5.0):
|
||||
raise ValueError(f"Rating must be between 0.0 and 5.0, got {value}")
|
||||
return super().__new__(cls, val)
|
||||
|
||||
|
||||
class LanguageISO(str):
|
||||
"""Valid ISO language code, validated via the langcodes library."""
|
||||
|
||||
def __new__(cls, value: str = "") -> LanguageISO:
|
||||
val = str(value)
|
||||
if val:
|
||||
try:
|
||||
if not Language.get(val).is_valid():
|
||||
raise ValueError(f"Invalid ISO language code: {value!r}")
|
||||
except ValueError:
|
||||
raise
|
||||
except Exception as e:
|
||||
raise ValueError(f"Invalid ISO language code: {value!r}") from e
|
||||
return super().__new__(cls, val)
|
||||
@@ -0,0 +1,21 @@
|
||||
"""CBZ library-specific exceptions."""
|
||||
|
||||
|
||||
class CBZError(Exception):
|
||||
"""Base class for all CBZ errors."""
|
||||
|
||||
|
||||
class InvalidImageError(CBZError):
|
||||
"""The provided image is invalid or in an unsupported format."""
|
||||
|
||||
|
||||
class EmptyArchiveError(CBZError):
|
||||
"""The archive contains no valid images."""
|
||||
|
||||
|
||||
class InvalidMetadataError(CBZError):
|
||||
"""The ComicInfo.xml metadata is invalid or corrupted."""
|
||||
|
||||
|
||||
class UnsupportedFormatError(CBZError):
|
||||
"""The file format is not supported."""
|
||||
@@ -0,0 +1,122 @@
|
||||
"""
|
||||
Data models for ComicInfo metadata.
|
||||
|
||||
Uses dataclasses with field metadata for automatic mapping
|
||||
to/from the ComicInfo XML format.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass, field, fields
|
||||
from typing import Any, Optional
|
||||
|
||||
from cbz.constants import (
|
||||
AgeRating,
|
||||
Format,
|
||||
LanguageISO,
|
||||
Manga,
|
||||
PageType,
|
||||
Rating,
|
||||
YesNo
|
||||
)
|
||||
|
||||
|
||||
def xml_field(xml_name: str, is_attribute: bool = False, **kwargs: Any) -> Any:
|
||||
"""Create a dataclass field with XML mapping metadata.
|
||||
|
||||
Args:
|
||||
xml_name: Corresponding XML element or attribute name.
|
||||
is_attribute: True if this is an XML attribute (@ prefix), False for an element.
|
||||
**kwargs: Additional arguments passed to dataclasses.field().
|
||||
"""
|
||||
metadata = {"xml_name": xml_name, "is_attribute": is_attribute}
|
||||
return field(metadata=metadata, **kwargs)
|
||||
|
||||
|
||||
def _get_xml_mapping(cls: type) -> dict:
|
||||
"""Return the mapping {python_name: (xml_name, type, is_attribute)} for a dataclass."""
|
||||
mapping = {}
|
||||
for f in fields(cls):
|
||||
if "xml_name" in f.metadata:
|
||||
mapping[f.name] = (f.metadata["xml_name"], f.type, f.metadata.get("is_attribute", False))
|
||||
return mapping
|
||||
|
||||
|
||||
@dataclass
|
||||
class PageModel:
|
||||
"""Data model for a comic page.
|
||||
|
||||
Each field corresponds to an XML attribute in the <Page/> element.
|
||||
Default values represent the absence of data.
|
||||
"""
|
||||
|
||||
type: PageType = xml_field("@Type", is_attribute=True, default=PageType.STORY)
|
||||
double: bool = xml_field("@DoublePage", is_attribute=True, default=False)
|
||||
image_size: int = xml_field("@ImageSize", is_attribute=True, default=0)
|
||||
key: str = xml_field("@Key", is_attribute=True, default="")
|
||||
bookmark: str = xml_field("@Bookmark", is_attribute=True, default="")
|
||||
image_width: int = xml_field("@ImageWidth", is_attribute=True, default=0)
|
||||
image_height: int = xml_field("@ImageHeight", is_attribute=True, default=0)
|
||||
|
||||
# Internal fields (not mapped to XML)
|
||||
suffix: str = field(default="", repr=False)
|
||||
name: str = field(default="", repr=False)
|
||||
|
||||
|
||||
@dataclass
|
||||
class ComicModel:
|
||||
"""Data model for comic metadata.
|
||||
|
||||
Each field corresponds to an XML element in <ComicInfo>.
|
||||
None values indicate missing data (not serialized to XML).
|
||||
"""
|
||||
|
||||
title: str = xml_field("Title", default="")
|
||||
series: str = xml_field("Series", default="")
|
||||
number: Optional[int] = xml_field("Number", default=None)
|
||||
count: Optional[int] = xml_field("Count", default=None)
|
||||
volume: Optional[int] = xml_field("Volume", default=None)
|
||||
alternate_series: str = xml_field("AlternateSeries", default="")
|
||||
alternate_number: Optional[int] = xml_field("AlternateNumber", default=None)
|
||||
alternate_count: Optional[int] = xml_field("AlternateCount", default=None)
|
||||
summary: str = xml_field("Summary", default="")
|
||||
notes: str = xml_field("Notes", default="")
|
||||
year: Optional[int] = xml_field("Year", default=None)
|
||||
month: Optional[int] = xml_field("Month", default=None)
|
||||
day: Optional[int] = xml_field("Day", default=None)
|
||||
writer: str = xml_field("Writer", default="")
|
||||
penciller: str = xml_field("Penciller", default="")
|
||||
inker: str = xml_field("Inker", default="")
|
||||
colorist: str = xml_field("Colorist", default="")
|
||||
letterer: str = xml_field("Letterer", default="")
|
||||
cover_artist: str = xml_field("CoverArtist", default="")
|
||||
editor: str = xml_field("Editor", default="")
|
||||
translator: str = xml_field("Translator", default="")
|
||||
publisher: str = xml_field("Publisher", default="")
|
||||
imprint: str = xml_field("Imprint", default="")
|
||||
genre: str = xml_field("Genre", default="")
|
||||
tags: str = xml_field("Tags", default="")
|
||||
web: str = xml_field("Web", default="")
|
||||
format: Format = xml_field("Format", default=Format.UNKNOWN)
|
||||
ean: str = xml_field("EAN", default="")
|
||||
black_white: YesNo = xml_field("BlackAndWhite", default=YesNo.UNKNOWN)
|
||||
manga: Manga = xml_field("Manga", default=Manga.UNKNOWN)
|
||||
characters: str = xml_field("Characters", default="")
|
||||
teams: str = xml_field("Teams", default="")
|
||||
locations: str = xml_field("Locations", default="")
|
||||
scan_information: str = xml_field("ScanInformation", default="")
|
||||
story_arc: str = xml_field("StoryArc", default="")
|
||||
story_arc_number: Optional[int] = xml_field("StoryArcNumber", default=None)
|
||||
series_group: str = xml_field("SeriesGroup", default="")
|
||||
age_rating: AgeRating = xml_field("AgeRating", default=AgeRating.UNKNOWN)
|
||||
main_character_or_team: str = xml_field("MainCharacterOrTeam", default="")
|
||||
review: str = xml_field("Review", default="")
|
||||
language_iso: LanguageISO = xml_field("LanguageISO", default=LanguageISO(""))
|
||||
community_rating: Optional[Rating] = xml_field("CommunityRating", default=None)
|
||||
added: str = xml_field("Added", default="")
|
||||
released: str = xml_field("Released", default="")
|
||||
file_size: Optional[int] = xml_field("FileSize", default=None)
|
||||
file_modified_time: str = xml_field("FileModifiedTime", default="")
|
||||
file_creation_time: str = xml_field("FileCreationTime", default="")
|
||||
book_price: str = xml_field("BookPrice", default="")
|
||||
custom_values_store: str = xml_field("CustomValuesStore", default="")
|
||||
@@ -0,0 +1,120 @@
|
||||
"""
|
||||
Comic page management module.
|
||||
|
||||
Provides the PageInfo class to load, manipulate and save
|
||||
individual comic pages (images).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
from dataclasses import dataclass, field
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
|
||||
from PIL import Image
|
||||
|
||||
from cbz.constants import IMAGE_FORMATS
|
||||
from cbz.exceptions import InvalidImageError
|
||||
from cbz.models import PageModel
|
||||
|
||||
|
||||
@dataclass
|
||||
class PageInfo(PageModel):
|
||||
"""Represents a comic page with its image content.
|
||||
|
||||
Inherits from PageModel for XML metadata and adds binary image
|
||||
content management. Image metadata (dimensions, size, format)
|
||||
is automatically extracted when content is assigned.
|
||||
|
||||
Attributes:
|
||||
_content: Binary image data (accessed via the content property).
|
||||
"""
|
||||
|
||||
_content: bytes = field(default=b"", repr=False, compare=False)
|
||||
|
||||
@property
|
||||
def content(self) -> bytes:
|
||||
"""Binary image data."""
|
||||
return self._content
|
||||
|
||||
@content.setter
|
||||
def content(self, value: bytes) -> None:
|
||||
"""Set content and automatically extract image metadata."""
|
||||
try:
|
||||
with Image.open(BytesIO(value)) as img:
|
||||
self.suffix = f".{img.format.lower()}"
|
||||
if self.suffix not in IMAGE_FORMATS:
|
||||
raise InvalidImageError(f"Unsupported image format: {self.suffix}")
|
||||
self.image_width = img.width
|
||||
self.image_height = img.height
|
||||
except InvalidImageError:
|
||||
raise
|
||||
except Exception as e:
|
||||
raise InvalidImageError(f"Unable to read image: {e}") from e
|
||||
self.image_size = len(value)
|
||||
self._content = value
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
"""Validate content if provided at initialization."""
|
||||
if self._content:
|
||||
self.content = self._content
|
||||
|
||||
@classmethod
|
||||
def loads(cls, data: Union[str, bytes], **kwargs) -> PageInfo:
|
||||
"""Create a PageInfo from raw bytes or base64-encoded data.
|
||||
|
||||
Args:
|
||||
data: Binary image data or base64-encoded string.
|
||||
**kwargs: Additional attributes (type, bookmark, etc.).
|
||||
|
||||
Returns:
|
||||
PageInfo instance with loaded content.
|
||||
|
||||
Raises:
|
||||
InvalidImageError: If the data is empty or invalid.
|
||||
ValueError: If the data type is not str or bytes.
|
||||
"""
|
||||
if isinstance(data, str):
|
||||
data = base64.b64decode(data)
|
||||
if not isinstance(data, bytes):
|
||||
raise ValueError(f"Expected bytes or base64 str, got {type(data).__name__}")
|
||||
if not data or data.isspace():
|
||||
raise InvalidImageError("Empty or null image data")
|
||||
|
||||
page = cls(**kwargs)
|
||||
page.content = data
|
||||
return page
|
||||
|
||||
@classmethod
|
||||
def load(cls, path: Union[Path, str], **kwargs) -> PageInfo:
|
||||
"""Create a PageInfo from an image file.
|
||||
|
||||
Args:
|
||||
path: Path to the image file.
|
||||
**kwargs: Additional attributes (type, bookmark, etc.).
|
||||
|
||||
Returns:
|
||||
PageInfo instance with file content loaded.
|
||||
|
||||
Raises:
|
||||
FileNotFoundError: If the file does not exist.
|
||||
InvalidImageError: If the image is invalid.
|
||||
"""
|
||||
path = Path(path)
|
||||
kwargs.setdefault("name", path.name)
|
||||
return cls.loads(path.read_bytes(), **kwargs)
|
||||
|
||||
def show(self) -> None:
|
||||
"""Display the page in the default image viewer."""
|
||||
with Image.open(BytesIO(self.content)) as img:
|
||||
img.show()
|
||||
|
||||
def save(self, path: Union[Path, str]) -> None:
|
||||
"""Save the page to a file.
|
||||
|
||||
Args:
|
||||
path: Destination file path.
|
||||
"""
|
||||
Path(path).write_bytes(self.content)
|
||||
@@ -0,0 +1,313 @@
|
||||
"""
|
||||
Tkinter-based graphical comic reader.
|
||||
|
||||
Provides a viewing interface with page navigation, zoom,
|
||||
scrolling and metadata display.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import tkinter as tk
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from tkinter import ttk
|
||||
from typing import Optional
|
||||
|
||||
try:
|
||||
from ctypes import windll
|
||||
except ImportError:
|
||||
windll = None
|
||||
|
||||
from PIL import Image, ImageTk
|
||||
|
||||
from cbz.comic import ComicInfo
|
||||
from cbz.page import PageInfo
|
||||
from cbz.utils import readable_size, ico_to_png
|
||||
|
||||
PARENT = Path(__file__).parent
|
||||
CTRL_KEY = 0x4 # Tkinter event.state bitmask for the Ctrl modifier
|
||||
|
||||
|
||||
class Player:
|
||||
"""Comic reader with Tkinter graphical interface.
|
||||
|
||||
Displays comic pages with navigation, zoom and
|
||||
a metadata summary page.
|
||||
|
||||
Attributes:
|
||||
comic: The comic to display.
|
||||
current_page: Index of the current page (-1 = summary).
|
||||
root: Main Tkinter window.
|
||||
"""
|
||||
|
||||
def __init__(self, comic: ComicInfo) -> None:
|
||||
"""Initialize the reader with a comic.
|
||||
|
||||
Args:
|
||||
comic: ComicInfo instance to display.
|
||||
"""
|
||||
self.comic = comic
|
||||
self.current_page: int = -1
|
||||
self.max_zoom_factor: Optional[float] = None
|
||||
self.zoom_factor: Optional[float] = None
|
||||
self.img_original: Optional[Image.Image] = None
|
||||
|
||||
# Window initialization
|
||||
self.root = tk.Tk()
|
||||
self.root.title(self._get_window_title())
|
||||
self.root.geometry(self._get_initial_geometry())
|
||||
self._set_icon()
|
||||
|
||||
# Main frame
|
||||
self.main_frame = ttk.Frame(self.root)
|
||||
self.main_frame.pack(fill=tk.BOTH, expand=True)
|
||||
|
||||
# Display canvas
|
||||
self.canvas = tk.Canvas(self.main_frame, bg="white")
|
||||
self.canvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
|
||||
|
||||
# Navigation buttons
|
||||
self._create_buttons()
|
||||
|
||||
# Summary text widget
|
||||
self._init_summary_text()
|
||||
|
||||
# Initial display
|
||||
self.show_page()
|
||||
|
||||
# Keyboard shortcuts and events
|
||||
self._bind_keys()
|
||||
|
||||
# Resize tracking
|
||||
self.previous_width = self.root.winfo_width()
|
||||
self.previous_height = self.root.winfo_height()
|
||||
self.resize_timer: Optional[str] = None
|
||||
|
||||
def _set_icon(self) -> None:
|
||||
"""Set the application icon."""
|
||||
icon_path = PARENT / "cbz.ico"
|
||||
if os.name == "nt" and windll is not None:
|
||||
windll.shell32.SetCurrentProcessExplicitAppUserModelID("cbz.player")
|
||||
self.root.iconbitmap(icon_path)
|
||||
else:
|
||||
image = ico_to_png(icon_path)
|
||||
self.root.iconphoto(True, tk.PhotoImage(data=image.getvalue()))
|
||||
|
||||
def _get_window_title(self) -> str:
|
||||
"""Build the window title."""
|
||||
if self.comic.series and self.comic.title:
|
||||
return f"{self.comic.series} - {self.comic.title}"
|
||||
return self.comic.title or self.__class__.__name__
|
||||
|
||||
def _get_initial_geometry(self) -> str:
|
||||
"""Calculate the initial window geometry."""
|
||||
margin_w = self.root.winfo_screenwidth() * 0.1
|
||||
margin_h = self.root.winfo_screenheight() * 0.1
|
||||
avail_w = self.root.winfo_screenwidth() - 2 * margin_w
|
||||
avail_h = self.root.winfo_screenheight() - 2 * margin_h
|
||||
|
||||
screen_w = int(avail_h * 0.63)
|
||||
screen_h = int(avail_h)
|
||||
|
||||
if self.comic.pages:
|
||||
# Use minimum dimensions across all pages
|
||||
img_w = self.comic.pages[0].image_width
|
||||
img_h = self.comic.pages[0].image_height
|
||||
for page in self.comic.pages[1:]:
|
||||
if page.image_width <= img_w and page.image_height <= img_h:
|
||||
img_w = page.image_width
|
||||
img_h = page.image_height
|
||||
|
||||
scale = min(avail_w / img_w, avail_h / img_h)
|
||||
init_w = int(img_w * scale * 0.94)
|
||||
init_h = int(img_h * scale)
|
||||
else:
|
||||
init_w = screen_w
|
||||
init_h = screen_h
|
||||
|
||||
if 100 / screen_w * init_w < 50.0:
|
||||
init_w = screen_w
|
||||
|
||||
x = self.root.winfo_screenwidth() // 2 - init_w // 2
|
||||
y = self.root.winfo_screenheight() // 2 - init_h // 2
|
||||
return f"{init_w}x{init_h}+{x}+{y}"
|
||||
|
||||
def _create_buttons(self) -> None:
|
||||
"""Create navigation buttons."""
|
||||
button_frame = ttk.Frame(self.main_frame, height=10)
|
||||
button_frame.pack(side=tk.BOTTOM, pady=10)
|
||||
|
||||
self.prev_button = ttk.Button(button_frame, text="Previous", command=self.on_previous)
|
||||
self.prev_button.pack(side=tk.LEFT, padx=10)
|
||||
|
||||
self.page_index_label = ttk.Label(
|
||||
button_frame, text=f"{self.current_page + 1}/{len(self.comic)}"
|
||||
)
|
||||
self.page_index_label.pack(side=tk.LEFT, padx=10)
|
||||
|
||||
self.next_button = ttk.Button(button_frame, text="Next", command=self.on_next)
|
||||
self.next_button.pack(side=tk.LEFT, padx=10)
|
||||
|
||||
exit_button = ttk.Button(button_frame, text="Exit", command=self.root.quit)
|
||||
exit_button.pack(side=tk.RIGHT, padx=10)
|
||||
|
||||
def _init_summary_text(self) -> None:
|
||||
"""Initialize the metadata summary text widget."""
|
||||
self.summary_text = tk.Text(self.canvas, wrap=tk.WORD, bg="white", bd=0, padx=10, pady=10)
|
||||
self.summary_text.tag_configure("bold", font=("Arial", 13, "bold"))
|
||||
self.summary_text.tag_configure("normal", font=("Arial", 12), lmargin1=10, lmargin2=10)
|
||||
self.summary_text.config(state=tk.DISABLED)
|
||||
|
||||
def show_page(self) -> None:
|
||||
"""Display the current page (summary or image)."""
|
||||
self.canvas.delete("all")
|
||||
|
||||
if self.current_page == -1:
|
||||
self._show_summary_page()
|
||||
elif self.current_page < len(self.comic):
|
||||
self._show_image_page()
|
||||
|
||||
self.prev_button.config(state=tk.DISABLED if self.current_page == -1 else tk.NORMAL)
|
||||
self.next_button.config(
|
||||
state=tk.DISABLED if self.current_page + 1 == len(self.comic) else tk.NORMAL
|
||||
)
|
||||
self.page_index_label.config(text=f"{self.current_page + 1}/{len(self.comic)}")
|
||||
|
||||
def _show_summary_page(self) -> None:
|
||||
"""Display the summary page with metadata."""
|
||||
self.root.update_idletasks()
|
||||
infos = self.comic.get_info()
|
||||
|
||||
self.summary_text.config(state=tk.NORMAL)
|
||||
self.summary_text.delete("1.0", tk.END)
|
||||
|
||||
for key, value in infos.items():
|
||||
if not (key.startswith("@") or key == "Pages"):
|
||||
if key == "FileSize":
|
||||
value = readable_size(value)
|
||||
self.summary_text.insert(tk.END, f"{key}\n", "bold")
|
||||
self.summary_text.insert(tk.END, f"{value}\n\n", "normal")
|
||||
|
||||
self.summary_text.config(state=tk.DISABLED)
|
||||
self.summary_text.place(relwidth=1, relheight=1)
|
||||
|
||||
def _show_image_page(self) -> None:
|
||||
"""Display an image page centered on the canvas."""
|
||||
self.summary_text.place_forget()
|
||||
if self.img_original is not None:
|
||||
self.img_original.close()
|
||||
page: PageInfo = self.comic[self.current_page]
|
||||
self.img_original = Image.open(BytesIO(page.content))
|
||||
self._display_image()
|
||||
|
||||
def _display_image(self) -> None:
|
||||
"""Display the image with the current zoom level."""
|
||||
if not self.zoom_factor:
|
||||
self.max_zoom_factor = min(
|
||||
self.canvas.winfo_width() / self.img_original.width,
|
||||
self.canvas.winfo_height() / self.img_original.height,
|
||||
)
|
||||
self.zoom_factor = self.max_zoom_factor
|
||||
|
||||
new_w = int(self.img_original.width * self.zoom_factor)
|
||||
new_h = int(self.img_original.height * self.zoom_factor)
|
||||
img = self.img_original.resize((new_w, new_h), Image.Resampling.LANCZOS)
|
||||
|
||||
self.canvas.image = ImageTk.PhotoImage(img)
|
||||
x = max(0, (self.canvas.winfo_width() - new_w) // 2)
|
||||
y = max(0, (self.canvas.winfo_height() - new_h) // 2)
|
||||
self.canvas.create_image(x, y, anchor=tk.NW, image=self.canvas.image)
|
||||
|
||||
canvas_w = max(new_w, self.canvas.winfo_width())
|
||||
canvas_h = max(new_h, self.canvas.winfo_height())
|
||||
self.canvas.config(scrollregion=(0, 0, canvas_w, canvas_h))
|
||||
|
||||
def _bind_keys(self) -> None:
|
||||
"""Configure keyboard shortcuts and events."""
|
||||
self.root.bind("<Left>", lambda _: self.on_previous())
|
||||
self.root.bind("<Right>", lambda _: self.on_next())
|
||||
self.root.bind("<Control-q>", lambda _: self.root.quit())
|
||||
self.root.bind("<Configure>", lambda e: self.on_window(e))
|
||||
|
||||
self.root.bind("<Control-MouseWheel>", self.on_zoom)
|
||||
self.canvas.bind_all("<MouseWheel>", self._on_mouse_wheel)
|
||||
self.canvas.bind_all("<Shift-MouseWheel>", self._on_shift_mouse_wheel)
|
||||
|
||||
self.root.bind("<KeyPress-plus>", lambda _: self.on_zoom_key(True))
|
||||
self.root.bind("<KeyPress-minus>", lambda _: self.on_zoom_key(False))
|
||||
|
||||
def on_zoom_key(self, zoom_in: bool) -> None:
|
||||
"""Handle keyboard zoom (+ / -)."""
|
||||
event = tk.Event()
|
||||
event.delta = 120 if zoom_in else -120
|
||||
self.on_zoom(event)
|
||||
|
||||
def on_zoom(self, event: tk.Event) -> None:
|
||||
"""Handle zoom with Ctrl + mouse wheel."""
|
||||
if self.current_page == -1:
|
||||
return
|
||||
|
||||
if event.delta > 0:
|
||||
self.zoom_factor *= 1.1
|
||||
elif event.delta < 0:
|
||||
self.zoom_factor /= 1.1
|
||||
|
||||
min_zoom = min(
|
||||
self.canvas.winfo_width() / self.img_original.width,
|
||||
self.canvas.winfo_height() / self.img_original.height,
|
||||
)
|
||||
if self.zoom_factor < min_zoom:
|
||||
self.zoom_factor = min_zoom
|
||||
|
||||
self._display_image()
|
||||
|
||||
def _on_mouse_wheel(self, event: tk.Event) -> None:
|
||||
"""Handle vertical scrolling."""
|
||||
if self.current_page == -1 or (event.state & CTRL_KEY):
|
||||
return
|
||||
self.canvas.yview_scroll(int(-1 * (event.delta / 120)), "units")
|
||||
|
||||
def _on_shift_mouse_wheel(self, event: tk.Event) -> None:
|
||||
"""Handle horizontal scrolling."""
|
||||
if self.current_page == -1 or (event.state & CTRL_KEY):
|
||||
return
|
||||
self.canvas.xview_scroll(int(-1 * (event.delta / 120)), "units")
|
||||
|
||||
def on_previous(self) -> None:
|
||||
"""Navigate to the previous page."""
|
||||
if self.current_page == -1:
|
||||
return
|
||||
self.current_page -= 1
|
||||
self.zoom_factor = None
|
||||
self.show_page()
|
||||
|
||||
def on_next(self) -> None:
|
||||
"""Navigate to the next page."""
|
||||
if self.current_page < len(self.comic) - 1:
|
||||
self.current_page += 1
|
||||
self.zoom_factor = None
|
||||
self.show_page()
|
||||
|
||||
def on_window(self, event: tk.Event) -> None:
|
||||
"""Handle window resize."""
|
||||
if event.width != self.previous_width or event.height != self.previous_height:
|
||||
self.previous_width = event.width
|
||||
self.previous_height = event.height
|
||||
|
||||
if self.resize_timer:
|
||||
self.root.after_cancel(self.resize_timer)
|
||||
self.resize_timer = self.root.after(200, self._on_resize)
|
||||
|
||||
def _on_resize(self) -> None:
|
||||
"""React to window resize with delay."""
|
||||
if self.current_page == -1:
|
||||
return
|
||||
if self.zoom_factor == self.max_zoom_factor:
|
||||
self.zoom_factor = None
|
||||
self._display_image()
|
||||
self.resize_timer = None
|
||||
|
||||
def run(self) -> None:
|
||||
"""Start the reader main loop."""
|
||||
self.root.mainloop()
|
||||
@@ -0,0 +1,35 @@
|
||||
"""Utility functions for the CBZ library."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
|
||||
from PIL import Image
|
||||
from PIL.IcoImagePlugin import IcoFile
|
||||
|
||||
|
||||
def readable_size(size: int, decimal: int = 2) -> str:
|
||||
"""Convert a byte size to a human-readable string (KB, MB, etc.)."""
|
||||
for unit in ("B", "KB", "MB", "GB", "TB"):
|
||||
if size < 1024:
|
||||
return f"{size:.{decimal}f} {unit}"
|
||||
size /= 1024
|
||||
return f"{size:.{decimal}f} PB"
|
||||
|
||||
|
||||
def ico_to_png(path: Path) -> BytesIO:
|
||||
"""Convert the largest icon in an ICO file to PNG format."""
|
||||
with Image.open(BytesIO(path.read_bytes())) as image:
|
||||
if image.format != "ICO":
|
||||
raise ValueError(f"Expected ICO format, got {image.format}")
|
||||
|
||||
icon: IcoFile = image.ico
|
||||
max_size = max(icon.sizes(), key=lambda s: s[0] + s[1])
|
||||
largest = icon.getimage(size=max_size)
|
||||
|
||||
buf = BytesIO()
|
||||
largest.save(buf, format="PNG")
|
||||
largest.close()
|
||||
buf.seek(0)
|
||||
return buf
|
||||
@@ -0,0 +1,615 @@
|
||||
# RFC: CBZ (Comic Book ZIP) Format Specification
|
||||
|
||||
**Version:** 1.0
|
||||
**Status:** Informational
|
||||
**Date:** 2026-04-06
|
||||
**Authors:** hyugogirubato, contributors
|
||||
|
||||
---
|
||||
|
||||
## 1. Abstract
|
||||
|
||||
This document specifies the CBZ (Comic Book ZIP) file format, a widely-adopted standard for packaging and distributing digital comic books, manga, and graphic novels. CBZ files are ZIP archives containing sequential image files and an optional XML metadata descriptor (`ComicInfo.xml`). This RFC consolidates existing community practices, the ComicInfo XML schema (versions 1.0 through 2.1), and implementation experience into a single authoritative reference.
|
||||
|
||||
## 2. Status of This Document
|
||||
|
||||
This document is an informational specification. It describes the CBZ format as implemented by major comic book readers and management tools including ComicRack, Kavita, Komga, Calibre, YACReader, and others. The format originated from the ComicRack application and has been extended by the community through the anansi-project.
|
||||
|
||||
## 3. Terminology
|
||||
|
||||
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.
|
||||
|
||||
| Term | Definition |
|
||||
|-------------------|---------------------------------------------------------------------------------|
|
||||
| **CBZ** | Comic Book ZIP - A ZIP archive containing comic book pages as images |
|
||||
| **CBR** | Comic Book RAR - Similar format using RAR compression (read-only in most tools) |
|
||||
| **ComicInfo.xml** | XML metadata descriptor file embedded in the archive |
|
||||
| **Page** | A single image representing one page of the comic |
|
||||
| **Double Page** | A single image representing a two-page spread |
|
||||
|
||||
## 4. File Format Overview
|
||||
|
||||
### 4.1 MIME Type
|
||||
|
||||
```
|
||||
application/vnd.comicbook+zip
|
||||
```
|
||||
|
||||
The file extension is `.cbz` (case-insensitive).
|
||||
|
||||
### 4.2 Archive Structure
|
||||
|
||||
A CBZ file is a standard ZIP archive (as defined in PKWARE APPNOTE) with the following structure:
|
||||
|
||||
```
|
||||
archive.cbz (ZIP)
|
||||
+-- ComicInfo.xml (OPTIONAL - metadata descriptor)
|
||||
+-- page-001.jpg (image file)
|
||||
+-- page-002.jpg (image file)
|
||||
+-- page-003.png (image file)
|
||||
+-- ...
|
||||
```
|
||||
|
||||
### 4.3 Archive Requirements
|
||||
|
||||
1. The archive MUST be a valid ZIP file conforming to PKWARE's ZIP Application Note.
|
||||
2. The archive SHOULD use `ZIP_STORED` (no compression) as the compression method, since image formats already employ their own compression. Using `ZIP_DEFLATED` is permitted but offers negligible size reduction at a performance cost.
|
||||
3. The archive MUST contain at least one image file.
|
||||
4. The archive MAY contain a `ComicInfo.xml` metadata file at the root level.
|
||||
5. The archive MUST NOT contain executable files, scripts, or other non-image/non-metadata content at the root level. Subdirectories (e.g., `__MACOSX/`) SHOULD be ignored by readers.
|
||||
|
||||
### 4.4 File Naming
|
||||
|
||||
1. Image files SHOULD be named to sort in reading order using standard lexicographic (alphabetical) sorting.
|
||||
2. The RECOMMENDED naming convention is zero-padded sequential names: `page-001.ext`, `page-002.ext`, etc.
|
||||
3. Readers MUST sort image files alphabetically (case-insensitive) to determine page order when no `ComicInfo.xml` page index is present.
|
||||
4. The metadata file MUST be named exactly `ComicInfo.xml` (case-sensitive).
|
||||
|
||||
## 5. Supported Image Formats
|
||||
|
||||
### 5.1 Required Support
|
||||
|
||||
Conforming readers MUST support the following image formats:
|
||||
|
||||
| Format | Extensions | MIME Type |
|
||||
|--------|-----------------|--------------|
|
||||
| JPEG | `.jpg`, `.jpeg` | `image/jpeg` |
|
||||
| PNG | `.png` | `image/png` |
|
||||
|
||||
### 5.2 Recommended Support
|
||||
|
||||
Conforming readers SHOULD support:
|
||||
|
||||
| Format | Extensions | MIME Type |
|
||||
|--------|-----------------|--------------|
|
||||
| GIF | `.gif` | `image/gif` |
|
||||
| BMP | `.bmp` | `image/bmp` |
|
||||
| WebP | `.webp` | `image/webp` |
|
||||
| TIFF | `.tiff`, `.tif` | `image/tiff` |
|
||||
|
||||
### 5.3 Optional Support
|
||||
|
||||
Conforming readers MAY support:
|
||||
|
||||
| Format | Extensions | MIME Type |
|
||||
|---------|------------|--------------|
|
||||
| JPEG XL | `.jxl` | `image/jxl` |
|
||||
| AVIF | `.avif` | `image/avif` |
|
||||
|
||||
### 5.4 Image Guidelines
|
||||
|
||||
1. All image files within a single archive SHOULD use the same format for consistency.
|
||||
2. Images SHOULD be stored in their original resolution without additional compression artifacts.
|
||||
3. For optimal compatibility, JPEG is RECOMMENDED for photographic/scanned content, and PNG for digitally-produced content with sharp edges or transparency.
|
||||
4. Readers MUST determine page dimensions from the actual image data, not from metadata alone.
|
||||
|
||||
## 6. ComicInfo.xml Metadata Specification
|
||||
|
||||
### 6.1 Overview
|
||||
|
||||
The `ComicInfo.xml` file is an XML document that describes the comic book's metadata and page structure. It follows the ComicInfo schema originally developed for the ComicRack application.
|
||||
|
||||
### 6.2 XML Declaration
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
```
|
||||
|
||||
The file MUST use UTF-8 encoding.
|
||||
|
||||
### 6.3 Root Element
|
||||
|
||||
```xml
|
||||
|
||||
<ComicInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
...
|
||||
</ComicInfo>
|
||||
```
|
||||
|
||||
The root element MUST be `<ComicInfo>`. The XML namespace declarations are RECOMMENDED for schema validation but not strictly required for parsing.
|
||||
|
||||
### 6.4 Comic Metadata Elements
|
||||
|
||||
All metadata elements are OPTIONAL. They appear as child elements of `<ComicInfo>` in the order specified below. Absent elements indicate unknown or unset values.
|
||||
|
||||
#### 6.4.1 Identification
|
||||
|
||||
| Element | Type | Default | Description |
|
||||
|-------------------|-------------|---------|----------------------------------------------------------------------------|
|
||||
| `Title` | `xs:string` | `""` | Title of the comic issue |
|
||||
| `Series` | `xs:string` | `""` | Name of the comic series |
|
||||
| `Number` | `xs:string` | `""` | Issue number within the series (string to support "1.5", "Annual 1", etc.) |
|
||||
| `Count` | `xs:int` | `-1` | Total number of issues in the series (-1 = unknown) |
|
||||
| `Volume` | `xs:int` | `-1` | Volume number (-1 = unknown) |
|
||||
| `AlternateSeries` | `xs:string` | `""` | Alternate series name (for crossovers, reprints) |
|
||||
| `AlternateNumber` | `xs:string` | `""` | Issue number in the alternate series |
|
||||
| `AlternateCount` | `xs:int` | `-1` | Total issues in the alternate series |
|
||||
|
||||
**Notes:**
|
||||
|
||||
- `Number` is typed as string in the schema to accommodate non-integer issue numbers (e.g., "0.5", "Annual 3", "#1/2").
|
||||
- When `Count` is -1, the series is ongoing or the total is unknown.
|
||||
|
||||
#### 6.4.2 Descriptive
|
||||
|
||||
| Element | Type | Default | Description |
|
||||
|-------------|-------------|---------|-----------------------------------------------|
|
||||
| `Summary` | `xs:string` | `""` | Synopsis or description of the issue |
|
||||
| `Notes` | `xs:string` | `""` | Free-form notes (scan quality, source, etc.) |
|
||||
| `Genre` | `xs:string` | `""` | Genre(s), comma-separated |
|
||||
| `Tags` | `xs:string` | `""` | Tags/keywords, comma-separated |
|
||||
| `Web` | `xs:string` | `""` | URL to the comic's web page or source |
|
||||
| `EAN` | `xs:string` | `""` | European Article Number (ISBN/barcode) |
|
||||
| `BookPrice` | `xs:string` | `""` | Cover price (free-form string, e.g., "$3.99") |
|
||||
|
||||
**Notes:**
|
||||
|
||||
- `Genre` and `Tags` use comma-separated values. Readers SHOULD trim whitespace around each value.
|
||||
- `Web` SHOULD contain a valid URL but no validation is required.
|
||||
|
||||
#### 6.4.3 Publication Date
|
||||
|
||||
| Element | Type | Default | Description |
|
||||
|---------|----------|---------|-----------------------------|
|
||||
| `Year` | `xs:int` | `-1` | Publication year (4 digits) |
|
||||
| `Month` | `xs:int` | `-1` | Publication month (1-12) |
|
||||
| `Day` | `xs:int` | `-1` | Publication day (1-31) |
|
||||
|
||||
**Notes:**
|
||||
|
||||
- A value of -1 indicates the date component is unknown.
|
||||
- Readers SHOULD NOT assume Month and Day are present when Year is set.
|
||||
|
||||
#### 6.4.4 Credits
|
||||
|
||||
| Element | Type | Default | Description |
|
||||
|---------------|-------------|---------|-----------------------------------|
|
||||
| `Writer` | `xs:string` | `""` | Writer(s), comma-separated |
|
||||
| `Penciller` | `xs:string` | `""` | Pencil artist(s), comma-separated |
|
||||
| `Inker` | `xs:string` | `""` | Inker(s), comma-separated |
|
||||
| `Colorist` | `xs:string` | `""` | Colorist(s), comma-separated |
|
||||
| `Letterer` | `xs:string` | `""` | Letterer(s), comma-separated |
|
||||
| `CoverArtist` | `xs:string` | `""` | Cover artist(s), comma-separated |
|
||||
| `Editor` | `xs:string` | `""` | Editor(s), comma-separated |
|
||||
| `Translator` | `xs:string` | `""` | Translator(s), comma-separated |
|
||||
|
||||
**Notes:**
|
||||
|
||||
- All credit fields support multiple names as comma-separated values.
|
||||
- The `Translator` field was added in schema v2.1.
|
||||
|
||||
#### 6.4.5 Publisher
|
||||
|
||||
| Element | Type | Default | Description |
|
||||
|-------------|-------------|---------|----------------------------------|
|
||||
| `Publisher` | `xs:string` | `""` | Publisher name |
|
||||
| `Imprint` | `xs:string` | `""` | Publisher's imprint or sub-label |
|
||||
|
||||
#### 6.4.6 Classification
|
||||
|
||||
| Element | Type | Allowed Values | Default | Description |
|
||||
|-----------------|-------------|---------------------------------------------|-----------|----------------------------------------------------|
|
||||
| `Format` | `xs:string` | (see section 6.5) | `""` | Publication format |
|
||||
| `BlackAndWhite` | `YesNo` | `Unknown`, `No`, `Yes` | `Unknown` | Whether the comic is black and white |
|
||||
| `Manga` | `Manga` | `Unknown`, `No`, `Yes`, `YesAndRightToLeft` | `Unknown` | Whether the comic is manga (and reading direction) |
|
||||
| `AgeRating` | `AgeRating` | (see section 6.7) | `Unknown` | Content age rating |
|
||||
| `LanguageISO` | `xs:string` | ISO 639 codes | `""` | Language code (e.g., "en", "fr", "ja") |
|
||||
|
||||
#### 6.4.7 Characters and Story
|
||||
|
||||
| Element | Type | Default | Description |
|
||||
|-----------------------|-------------|---------|----------------------------------|
|
||||
| `Characters` | `xs:string` | `""` | Character names, comma-separated |
|
||||
| `Teams` | `xs:string` | `""` | Team names, comma-separated |
|
||||
| `Locations` | `xs:string` | `""` | Location names, comma-separated |
|
||||
| `MainCharacterOrTeam` | `xs:string` | `""` | Primary character or team |
|
||||
| `StoryArc` | `xs:string` | `""` | Story arc name |
|
||||
| `StoryArcNumber` | `xs:string` | `""` | Position within the story arc |
|
||||
| `SeriesGroup` | `xs:string` | `""` | Series grouping or universe |
|
||||
|
||||
#### 6.4.8 Community
|
||||
|
||||
| Element | Type | Default | Description |
|
||||
|-------------------|-------------|---------|-------------------------------------------------|
|
||||
| `CommunityRating` | `Rating` | (none) | Community rating (0.0-5.0, single decimal) |
|
||||
| `Review` | `xs:string` | `""` | Review text |
|
||||
| `ScanInformation` | `xs:string` | `""` | Information about the scan/digitization process |
|
||||
|
||||
#### 6.4.9 File Metadata
|
||||
|
||||
| Element | Type | Default | Description |
|
||||
|--------------------|-------------|---------|-------------------------------------------|
|
||||
| `PageCount` | `xs:int` | `0` | Number of pages in the archive |
|
||||
| `FileSize` | `xs:int` | `""` | Total size of image files in bytes |
|
||||
| `FileCreationTime` | `xs:string` | `""` | Archive creation timestamp (ISO 8601) |
|
||||
| `FileModifiedTime` | `xs:string` | `""` | Archive modification timestamp (ISO 8601) |
|
||||
| `Added` | `xs:string` | `""` | Date added to library |
|
||||
| `Released` | `xs:string` | `""` | Release/publication date |
|
||||
|
||||
**Notes:**
|
||||
|
||||
- Timestamps SHOULD use ISO 8601 format: `YYYY-MM-DDThh:mm:ss.sssZ`
|
||||
- `PageCount` MUST match the actual number of image files in the archive.
|
||||
- `FileSize` represents the total uncompressed size of all image files, NOT the archive size.
|
||||
|
||||
#### 6.4.10 Custom Data
|
||||
|
||||
| Element | Type | Default | Description |
|
||||
|---------------------|-------------|---------|--------------------------------------------------|
|
||||
| `CustomValuesStore` | `xs:string` | `""` | Application-specific custom data (opaque string) |
|
||||
|
||||
### 6.5 Format Enumeration
|
||||
|
||||
The `Format` element accepts any string value, but the following are the recognized standard values:
|
||||
|
||||
```
|
||||
Annotation, Annual, Anthology, Black & White, Box-Set, Crossover,
|
||||
Director's Cut, Epilogue, Event, FCBD, Flyer, Giant-Size, Graphic Novel,
|
||||
Hard-Cover, King-Size, Limited Series, Magazine, NSFW, One-Shot, Point 1,
|
||||
Preview, Prologue, Reference, Review, Reviewed, Scanlation, Script,
|
||||
Series, Sketch, Special, Trade Paper Back, Web Comic, Year One
|
||||
```
|
||||
|
||||
Readers SHOULD accept these values case-insensitively. Alternative spellings exist in the wild (e.g., "TPB" for "Trade Paper Back", "WebComic" for "Web Comic") and readers SHOULD handle them gracefully.
|
||||
|
||||
### 6.6 Manga Enumeration
|
||||
|
||||
| Value | Description |
|
||||
|---------------------|-----------------------------------------------------|
|
||||
| `Unknown` | Reading direction not specified |
|
||||
| `No` | Western-style left-to-right reading |
|
||||
| `Yes` | Manga-style (may be left-to-right or right-to-left) |
|
||||
| `YesAndRightToLeft` | Manga with explicit right-to-left reading order |
|
||||
|
||||
Readers SHOULD use this value to determine the reading direction for page navigation and double-page spread orientation.
|
||||
|
||||
### 6.7 AgeRating Enumeration
|
||||
|
||||
| Value | Description |
|
||||
|-------------------|----------------------------------|
|
||||
| `Unknown` | Not rated |
|
||||
| `Adults Only 18+` | Adult content only |
|
||||
| `Early Childhood` | Suitable for very young children |
|
||||
| `Everyone` | Suitable for all ages |
|
||||
| `Everyone 10+` | Suitable for ages 10 and up |
|
||||
| `G` | General audiences |
|
||||
| `Kids to Adults` | Suitable for children to adults |
|
||||
| `M` | Mature content |
|
||||
| `MA15+` | Mature audiences 15+ |
|
||||
| `Mature 17+` | Mature audiences 17+ |
|
||||
| `PG` | Parental guidance suggested |
|
||||
| `R18+` | Restricted 18+ |
|
||||
| `Rating Pending` | Rating has not been assigned |
|
||||
| `Teen` | Suitable for teens |
|
||||
| `X18+` | Explicit content 18+ |
|
||||
|
||||
### 6.8 Rating Type
|
||||
|
||||
The `CommunityRating` element uses a decimal type:
|
||||
|
||||
- Minimum value: `0.0`
|
||||
- Maximum value: `5.0`
|
||||
- Precision: 1 decimal place (schema v2.1) or 2 decimal places (schema v2.0)
|
||||
|
||||
### 6.9 Pages Element
|
||||
|
||||
The `<Pages>` element contains an ordered list of `<Page>` elements describing each page in the archive.
|
||||
|
||||
```xml
|
||||
|
||||
<Pages>
|
||||
<Page Image="0" Type="FrontCover" ImageSize="245760" ImageWidth="800" ImageHeight="1200"/>
|
||||
<Page Image="1" Type="Story" DoublePage="false" ImageSize="198432" ImageWidth="800" ImageHeight="1200"/>
|
||||
<Page Image="2" Type="BackCover" ImageSize="210944" ImageWidth="800" ImageHeight="1200"/>
|
||||
</Pages>
|
||||
```
|
||||
|
||||
#### 6.9.1 Page Attributes
|
||||
|
||||
| Attribute | Type | Required | Default | Description |
|
||||
|---------------|-----------------|----------|---------|------------------------------------------------------|
|
||||
| `Image` | `xs:int` | **YES** | - | Zero-based index of the page in the sorted file list |
|
||||
| `Type` | `ComicPageType` | No | `Story` | Type/role of the page |
|
||||
| `DoublePage` | `xs:boolean` | No | `false` | Whether this is a double-page spread |
|
||||
| `ImageSize` | `xs:long` | No | `0` | Image file size in bytes |
|
||||
| `Key` | `xs:string` | No | `""` | Unique key for the page |
|
||||
| `Bookmark` | `xs:string` | No | `""` | Bookmark/chapter name for this page |
|
||||
| `ImageWidth` | `xs:int` | No | `-1` | Image width in pixels |
|
||||
| `ImageHeight` | `xs:int` | No | `-1` | Image height in pixels |
|
||||
|
||||
**Notes:**
|
||||
|
||||
- `Image` is the ONLY required attribute. It MUST be a zero-based index corresponding to the page's position in the alphabetically-sorted list of image files.
|
||||
- `Bookmark` was added in schema v2.0.
|
||||
- Readers SHOULD use actual image dimensions from the file rather than relying solely on `ImageWidth`/`ImageHeight` metadata.
|
||||
|
||||
#### 6.9.2 ComicPageType Enumeration
|
||||
|
||||
| Value | Description |
|
||||
|-----------------|--------------------------------------------|
|
||||
| `FrontCover` | Front cover image |
|
||||
| `InnerCover` | Inner cover or dust jacket |
|
||||
| `Roundup` | Recap or summary page |
|
||||
| `Story` | Regular story page (default) |
|
||||
| `Advertisement` | Advertisement page |
|
||||
| `Editorial` | Editorial or credits page |
|
||||
| `Letters` | Letters to the editor page |
|
||||
| `Preview` | Preview of upcoming issues |
|
||||
| `BackCover` | Back cover image |
|
||||
| `Other` | Other content not fitting above categories |
|
||||
| `Deleted` | Page marked for deletion (not displayed) |
|
||||
|
||||
**Notes:**
|
||||
|
||||
- The `FrontCover` page is typically used by readers as the thumbnail/cover image for the comic.
|
||||
- Pages of type `Deleted` SHOULD NOT be displayed to the user but MAY be retained in the archive.
|
||||
|
||||
## 7. Schema Evolution
|
||||
|
||||
### 7.1 Version History
|
||||
|
||||
| Version | Key Changes |
|
||||
|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| **1.0** | Initial schema. Core metadata fields, basic page info. `Manga` typed as `YesNo`. No `Bookmark`, `Tags`, `Translator`, `StoryArcNumber`, `AgeRating`, `CommunityRating`, `MainCharacterOrTeam`, `Review`, `Added`, `Released`, `FileSize`, `FileModifiedTime`, `FileCreationTime`, `BookPrice`, `CustomValuesStore`. |
|
||||
| **2.0** | Added `Characters`, `Teams`, `Locations`, `ScanInformation`, `StoryArc`, `SeriesGroup`, `AgeRating`, `CommunityRating`, `MainCharacterOrTeam`, `Review`. `Manga` gets its own type with `YesAndRightToLeft`. `Bookmark` added to pages. `Rating` type has 2 decimal places. |
|
||||
| **2.1** | Added `Translator`, `Tags`, `StoryArcNumber`, `Added`, `Released`, `FileSize`, `FileModifiedTime`, `FileCreationTime`, `BookPrice`, `CustomValuesStore`. `Rating` precision reduced to 1 decimal place. `Day` field added to date. |
|
||||
|
||||
### 7.2 Compatibility Guidelines
|
||||
|
||||
1. Writers SHOULD generate metadata conforming to the latest schema version (2.1).
|
||||
2. Readers MUST gracefully handle unknown elements by ignoring them (forward compatibility).
|
||||
3. Readers MUST handle missing optional elements by using specified defaults (backward compatibility).
|
||||
4. Writers SHOULD NOT include elements with default/empty values to minimize file size.
|
||||
|
||||
## 8. Related Formats
|
||||
|
||||
### 8.1 CBR (Comic Book RAR)
|
||||
|
||||
- Extension: `.cbr`
|
||||
- MIME Type: `application/vnd.comicbook-rar`
|
||||
- Identical internal structure but using RAR archive format instead of ZIP.
|
||||
- Requires external RAR extraction tools (e.g., `unrar`, `7zip`).
|
||||
- CBZ is RECOMMENDED over CBR for new archives due to the ubiquity of ZIP support.
|
||||
|
||||
### 8.2 CB7 (Comic Book 7z)
|
||||
|
||||
- Extension: `.cb7`
|
||||
- MIME Type: `application/x-cb7`
|
||||
- Uses 7-Zip archive format. Less common.
|
||||
|
||||
### 8.3 CBT (Comic Book TAR)
|
||||
|
||||
- Extension: `.cbt`
|
||||
- MIME Type: `application/x-cbt`
|
||||
- Uses TAR archive format. No compression. Rare.
|
||||
|
||||
### 8.4 PDF
|
||||
|
||||
- PDF files can contain embedded images and are sometimes used for digital comics.
|
||||
- PDF does not natively support ComicInfo metadata.
|
||||
- Conversion from PDF to CBZ involves extracting images; metadata must be added separately.
|
||||
|
||||
## 9. Implementation Considerations
|
||||
|
||||
### 9.1 Reading a CBZ File
|
||||
|
||||
A conforming reader MUST implement the following algorithm:
|
||||
|
||||
1. Open the file as a ZIP archive.
|
||||
2. List all entries and sort them alphabetically (case-insensitive).
|
||||
3. Check for `ComicInfo.xml` at the root level:
|
||||
- If present, parse it and extract metadata.
|
||||
- If absent or malformed, proceed with image-only mode.
|
||||
4. Filter entries to include only files with supported image extensions.
|
||||
5. Ignore directories, hidden files (starting with `.`), and OS-specific metadata folders (e.g., `__MACOSX/`).
|
||||
6. Load images in sorted order as the page sequence.
|
||||
7. If `ComicInfo.xml` contains a `<Pages>` section, use the `Image` attribute to map metadata to pages.
|
||||
|
||||
### 9.2 Writing a CBZ File
|
||||
|
||||
A conforming writer MUST implement the following:
|
||||
|
||||
1. Create a new ZIP archive with `ZIP_STORED` compression (RECOMMENDED).
|
||||
2. Add `ComicInfo.xml` as the first entry (RECOMMENDED for fast metadata access).
|
||||
3. Add image files in reading order with sequential, zero-padded names.
|
||||
4. Ensure `PageCount` matches the number of image files.
|
||||
5. Set `Image` attributes in `<Page>` elements as zero-based indices matching the sorted file order.
|
||||
6. Use UTF-8 encoding for the XML file.
|
||||
7. Self-close `<Page>` elements: use `<Page ... />` not `<Page ...></Page>`.
|
||||
|
||||
### 9.3 Character Encoding
|
||||
|
||||
1. `ComicInfo.xml` MUST use UTF-8 encoding.
|
||||
2. File names within the archive SHOULD use UTF-8 encoding.
|
||||
3. All text content in metadata fields MUST be valid UTF-8.
|
||||
|
||||
### 9.4 Error Handling
|
||||
|
||||
1. Readers SHOULD be lenient in parsing: accept minor deviations from the schema.
|
||||
2. Unknown XML elements SHOULD be silently ignored.
|
||||
3. Malformed `ComicInfo.xml` SHOULD NOT prevent reading the images.
|
||||
4. Unsupported image formats SHOULD be skipped with a warning.
|
||||
|
||||
## 10. Security Considerations
|
||||
|
||||
1. Readers MUST validate ZIP entries to prevent path traversal attacks (e.g., entries with `../` in their names).
|
||||
2. Readers SHOULD impose reasonable limits on image dimensions and file sizes to prevent resource exhaustion.
|
||||
3. Readers MUST NOT execute any content from the archive, even if it appears to be a script or executable.
|
||||
4. `CustomValuesStore` content MUST be treated as opaque and untrusted.
|
||||
5. URLs in the `Web` field SHOULD NOT be automatically fetched without user consent.
|
||||
|
||||
## 11. Complete Example
|
||||
|
||||
### 11.1 Minimal ComicInfo.xml
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ComicInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<Title>Example Issue #1</Title>
|
||||
<Series>Example Series</Series>
|
||||
<Number>1</Number>
|
||||
<PageCount>3</PageCount>
|
||||
<Pages>
|
||||
<Page Image="0" Type="FrontCover"/>
|
||||
<Page Image="1" Type="Story"/>
|
||||
<Page Image="2" Type="BackCover"/>
|
||||
</Pages>
|
||||
</ComicInfo>
|
||||
```
|
||||
|
||||
### 11.2 Full ComicInfo.xml
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ComicInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<Title>The Amazing Adventure #1</Title>
|
||||
<Series>The Amazing Adventure</Series>
|
||||
<Number>1</Number>
|
||||
<Count>12</Count>
|
||||
<Volume>1</Volume>
|
||||
<Summary>The hero embarks on an incredible journey through uncharted territory.</Summary>
|
||||
<Notes>Scanned from first printing</Notes>
|
||||
<Year>2024</Year>
|
||||
<Month>6</Month>
|
||||
<Day>15</Day>
|
||||
<Writer>Jane Smith</Writer>
|
||||
<Penciller>John Doe</Penciller>
|
||||
<Inker>John Doe</Inker>
|
||||
<Colorist>Alice Johnson</Colorist>
|
||||
<Letterer>Bob Williams</Letterer>
|
||||
<CoverArtist>John Doe</CoverArtist>
|
||||
<Editor>Carol Brown</Editor>
|
||||
<Translator>Pierre Dupont</Translator>
|
||||
<Publisher>Example Comics</Publisher>
|
||||
<Imprint>Example Prestige</Imprint>
|
||||
<Genre>Adventure, Fantasy</Genre>
|
||||
<Tags>hero, quest, dragons</Tags>
|
||||
<Web>https://example.com/amazing-adventure-1</Web>
|
||||
<Format>Series</Format>
|
||||
<EAN>9781234567890</EAN>
|
||||
<BlackAndWhite>No</BlackAndWhite>
|
||||
<Manga>No</Manga>
|
||||
<Characters>Hero, Sidekick, Villain</Characters>
|
||||
<Teams>The Adventurers</Teams>
|
||||
<Locations>The Kingdom, Dragon Mountain</Locations>
|
||||
<ScanInformation>600dpi scan, cleaned and leveled</ScanInformation>
|
||||
<StoryArc>The Dragon Wars</StoryArc>
|
||||
<StoryArcNumber>1</StoryArcNumber>
|
||||
<SeriesGroup>Example Universe</SeriesGroup>
|
||||
<AgeRating>Teen</AgeRating>
|
||||
<CommunityRating>4.5</CommunityRating>
|
||||
<MainCharacterOrTeam>Hero</MainCharacterOrTeam>
|
||||
<Review>Excellent start to a new series</Review>
|
||||
<LanguageISO>en</LanguageISO>
|
||||
<Added>2024-06-20T10:30:00.000Z</Added>
|
||||
<Released>2024-06-15T00:00:00.000Z</Released>
|
||||
<FileSize>15728640</FileSize>
|
||||
<FileCreationTime>2024-06-20T10:30:00.000Z</FileCreationTime>
|
||||
<FileModifiedTime>2024-06-20T10:30:00.000Z</FileModifiedTime>
|
||||
<PageCount>24</PageCount>
|
||||
<Pages>
|
||||
<Page Image="0" Type="FrontCover" ImageSize="524288" ImageWidth="1600" ImageHeight="2400" Bookmark="Cover"/>
|
||||
<Page Image="1" Type="Story" ImageSize="491520" ImageWidth="1600" ImageHeight="2400" Bookmark="Chapter 1"/>
|
||||
<Page Image="2" Type="Story" DoublePage="true" ImageSize="983040" ImageWidth="3200" ImageHeight="2400"/>
|
||||
<!-- ... pages 3-22 ... -->
|
||||
<Page Image="23" Type="BackCover" ImageSize="458752" ImageWidth="1600" ImageHeight="2400"/>
|
||||
</Pages>
|
||||
</ComicInfo>
|
||||
```
|
||||
|
||||
## 12. XSD Schema Reference (v2.1)
|
||||
|
||||
The normative XML Schema Definition for version 2.1 is provided in `docs/schema/v2.1/ComicInfo.xsd`.
|
||||
|
||||
Key type definitions:
|
||||
|
||||
```xml
|
||||
<!-- YesNo enumeration -->
|
||||
<xs:simpleType name="YesNo">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="Unknown"/>
|
||||
<xs:enumeration value="No"/>
|
||||
<xs:enumeration value="Yes"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<!-- Manga enumeration -->
|
||||
<xs:simpleType name="Manga">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="Unknown"/>
|
||||
<xs:enumeration value="No"/>
|
||||
<xs:enumeration value="Yes"/>
|
||||
<xs:enumeration value="YesAndRightToLeft"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<!-- Rating type (0.0 to 5.0) -->
|
||||
<xs:simpleType name="Rating">
|
||||
<xs:restriction base="xs:decimal">
|
||||
<xs:minInclusive value="0"/>
|
||||
<xs:maxInclusive value="5"/>
|
||||
<xs:fractionDigits value="1"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
|
||||
<!-- Page type enumeration -->
|
||||
<xs:simpleType name="ComicPageType">
|
||||
<xs:list>
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="FrontCover"/>
|
||||
<xs:enumeration value="InnerCover"/>
|
||||
<xs:enumeration value="Roundup"/>
|
||||
<xs:enumeration value="Story"/>
|
||||
<xs:enumeration value="Advertisement"/>
|
||||
<xs:enumeration value="Editorial"/>
|
||||
<xs:enumeration value="Letters"/>
|
||||
<xs:enumeration value="Preview"/>
|
||||
<xs:enumeration value="BackCover"/>
|
||||
<xs:enumeration value="Other"/>
|
||||
<xs:enumeration value="Deleted"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:list>
|
||||
</xs:simpleType>
|
||||
```
|
||||
|
||||
## 13. References
|
||||
|
||||
- **PKWARE ZIP Application Note** - ZIP file format specification
|
||||
- **ComicRack** - Original creator of the ComicInfo.xml format
|
||||
- **anansi-project** - Community maintenance of the ComicInfo schema (https://anansi-project.github.io)
|
||||
- **RFC 2119** - Key words for use in RFCs
|
||||
- **ISO 639** - Language code standards
|
||||
- **ISO 8601** - Date and time format
|
||||
|
||||
## 14. Acknowledgments
|
||||
|
||||
This specification was compiled from the collective work of the comic book reader community, including the original ComicRack application by cYo Soft, the anansi-project contributors, and the numerous developers who have implemented CBZ support in their applications.
|
||||
|
||||
---
|
||||
|
||||
*This document is provided as-is for informational purposes. The CBZ format is a community standard without a formal standards body. Implementers should prioritize interoperability with existing tools over strict schema conformance.*
|
||||
|
After Width: | Height: | Size: 124 KiB |
|
After Width: | Height: | Size: 53 KiB |
@@ -0,0 +1,51 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="512" height="512" viewBox="0 0 512 512">
|
||||
<defs>
|
||||
<clipPath id="clip-favicon">
|
||||
<rect width="512" height="512"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
<g id="favicon" clip-path="url(#clip-favicon)">
|
||||
<g id="clipboard" transform="translate(-23.514 -24.026)">
|
||||
<g id="_000000ff" data-name="#000000ff" transform="translate(23.966 24.026)">
|
||||
<path id="Path_1" data-name="Path 1" d="M169.389,31.663c.738-3.359,3.051-6.52,6.531-7.335,4.846-1.377,8.954,2.28,12.808,4.6,43.612,29.3,76.068,74.56,90.341,125.088.363,1.817,1.278-.463,1.333-1.046,8.733-27.819,26.068-52.313,47.1-72.225,24.086-22.775,52.72-40.4,83.073-53.491,3.579-1.344,7.148-3.491,11.1-3.15a8.832,8.832,0,0,1,7.511,7.577c1.6,8.767,2.963,17.588,4.5,26.366,15.154-5.4,30.3-10.87,45.573-15.914a8.733,8.733,0,0,1,10.87,4.692c4.78,10.628,9.251,21.41,13.976,32.071,5.991-3.106,11.861-6.454,17.885-9.493a8.785,8.785,0,0,1,11.267,2.5c1.6,2,1.718,4.648,1.762,7.093q-.033,159.185-.011,318.381c-.066,4.053.275,8.128-.275,12.159-.562,3.227-3.315,5.374-6.046,6.806Q429.13,469.256,329.709,522.4c-6.806,3.557-13.447,7.632-20.9,9.747a112.762,112.762,0,0,1-36.465,3.7c-11.322-.7-22.819-2.742-32.93-8.117q-102.72-54.7-205.43-109.482c-3.392-1.927-7.72-3.348-9.273-7.291-1.09-3.293-.628-6.839-.727-10.242q.1-161.415.044-322.842a8.992,8.992,0,0,1,5.33-8.844c2.941-1.388,6.322-.518,9.009,1.024,7.709,4.108,15.4,8.249,23.117,12.335,2.357-11.366,4.427-22.8,6.916-34.141.98-4.692,6.156-7.544,10.716-6.377,28.051,4.5,54.736,15.1,80.121,27.61q5.039-18.932,10.154-37.819M360.546,75.5c-19.714,14.736-37.8,32.4-50.176,53.844,30.143-29.229,67.7-49.5,106.509-64.758-.991-6.52-2.225-13-3.2-19.515A266.629,266.629,0,0,0,360.546,75.5M175.1,78.259C204.686,95.352,231.68,116.685,256,140.638c-14.482-37.236-39.615-70.661-72.39-93.656-3.018,10.374-5.628,20.87-8.5,31.278M83.761,60.616C81.845,70.782,79.719,80.9,77.737,91.057,134.059,120.947,190.259,151.09,246.57,181c8.48,3.106,17.632,3.976,26.575,4.725C237.4,142.268,193.211,105.088,142.164,80.9c-18.678-8.756-38.161-16.09-58.4-20.286m293.745,41.575a255.536,255.536,0,0,0-91.564,83.557c9.1-.848,18.447-1.674,27.037-4.945q87.737-46.867,175.529-93.59-5.617-12.885-11.178-25.782c-34.009,11.608-68.282,23.271-99.824,40.76M41.636,91.784c.055,103.579-.154,207.148.1,310.727q3.948,1.949,7.83,4.053c5.551,3.172,11.222,6.167,16.938,9.031v.165c1.905.98,3.811,1.971,5.694,2.974q81.608,43.563,163.238,87.06.05-152.66,0-305.32c-.011-1.828-.022-3.656-.044-5.474Q138.469,143.458,41.636,91.784M323.629,195.022c-.066,3.2-.077,6.4-.066,9.6q.033,150.595.022,301.2,93.866-49.84,187.577-99.945l-.055-.385c2.048-.936,4.1-1.905,6.156-2.852.308-103.6.044-207.225.132-310.837q-96.889,51.608-193.767,103.216m-70.507,5.991q-.1,137.049.011,274.1c12.974,1.806,26.178,2.654,39.251,1.355a119.414,119.414,0,0,0,13.557-1.586q-.017-137,0-274c-.925.187-2.753.551-3.667.738-12.148,1.6-24.416,2.533-36.652,1.289v-.33c-1.949-.154-3.9-.319-5.848-.485-2.225-.319-4.438-.694-6.652-1.079m-.033,291.74q-.033,11.085.011,22.17c2.709.793,5.441,1.531,8.15,2.346l4.284.661c10.385,1.189,21.1,1.4,31.344-.936a73.568,73.568,0,0,0,8.965-2.1c.2-7.357.055-14.714.1-22.059-4.042.352-8.106.584-12.1,1.311A214.472,214.472,0,0,1,253.09,492.753Z" transform="translate(-23.966 -24.026)"/>
|
||||
<path id="Path_2" data-name="Path 2" d="M457.7,142.458c5.264-3.128,12.742,1.057,12.786,7.181.242,18.018.066,36.046.088,54.064a9.319,9.319,0,0,1-5.507,8.756q-67.318,35.7-134.659,71.322c-3.095,1.542-6.09,3.733-9.659,3.855a8.814,8.814,0,0,1-8.689-8.855c-.121-17.7-.044-35.4-.033-53.095a9.162,9.162,0,0,1,5.253-8.932q70.209-37.153,140.419-74.3M329.611,230.167c.011,1.476.011,2.941.022,4.416-.033,9.945,0,19.89-.011,29.824Q388.8,233.1,447.937,201.731c1.641-.947,3.3-1.839,4.978-2.72.121-11.388.022-22.775.055-34.163Q391.3,197.524,329.611,230.167Z" transform="translate(5.217 -12.134)"/>
|
||||
<path id="Path_3" data-name="Path 3" d="M253.906,212.509c5.419-2.148,11.905,2.445,11.663,8.271.132,53.954.022,107.919.055,161.883.374,4.251-2.313,8.623-6.564,9.637-5.308,1.619-11.245-2.918-11-8.469-.121-54-.022-108-.055-161.993A9.061,9.061,0,0,1,253.906,212.509Z" transform="translate(-1.269 -4.983)"/>
|
||||
<path id="Path_4" data-name="Path 4" d="M253.861,384.521c5.408-2.17,11.916,2.39,11.707,8.2.143,8.48.033,16.971.044,25.463a9.075,9.075,0,0,1-5.892,9.35c-5.374,2.137-11.861-2.39-11.652-8.172q-.182-13.315-.011-26.641A8.733,8.733,0,0,1,253.861,384.521Z" transform="translate(-1.268 12.444)"/>
|
||||
</g>
|
||||
<g id="_fcf3e7ff" data-name="#fcf3e7ff" transform="translate(77.737 45.066)">
|
||||
<path id="Path_5" data-name="Path 5" d="M334.2,73.56a266.629,266.629,0,0,1,53.128-30.43c.98,6.52,2.214,13,3.2,19.515C351.718,77.9,314.163,98.174,284.02,127.4,296.4,105.96,314.483,88.3,334.2,73.56Z" transform="translate(-51.388 -43.13)" fill="#fcf3e7"/>
|
||||
<path id="Path_6" data-name="Path 6" d="M161.2,76.148c2.874-10.407,5.485-20.9,8.5-31.278,32.775,23,57.908,56.421,72.39,93.656C217.775,114.573,190.782,93.24,161.2,76.148Z" transform="translate(-63.832 -42.954)" fill="#fcf3e7"/>
|
||||
<path id="Path_7" data-name="Path 7" d="M78.814,57.25c20.242,4.2,39.725,11.531,58.4,20.286C188.264,101.721,232.449,138.9,268.2,182.36c-8.943-.749-18.095-1.619-26.575-4.725C185.312,147.724,129.112,117.58,72.79,87.691,74.772,77.536,76.9,67.415,78.814,57.25Z" transform="translate(-72.79 -41.699)" fill="#fcf3e7"/>
|
||||
<path id="Path_8" data-name="Path 8" d="M353.4,98.75c31.542-17.489,65.815-29.152,99.824-40.76q5.551,12.9,11.178,25.782-87.7,46.9-175.529,93.59c-8.59,3.271-17.941,4.1-27.037,4.945A255.536,255.536,0,0,1,353.4,98.75Z" transform="translate(-53.635 -41.624)" fill="#fcf3e7"/>
|
||||
</g>
|
||||
<g id="_c68315ff" data-name="#c68315ff" transform="translate(41.606 91.784)">
|
||||
<path id="Path_9" data-name="Path 9" d="M40.013,85.55q96.905,51.542,193.756,103.216c.022,1.817.033,3.645.044,5.474-7.2-3.414-14.152-7.335-21.2-11.057-47.2-25.242-94.5-50.286-141.707-75.54q-2.874-1.569-5.782-3.073c-5.595-2.919-11.1-6.013-16.751-8.822-.3,5.573-.319,11.156-.231,16.729q.05,115.655.011,231.289c-.132,18.855.275,37.72-.209,56.564q-3.882-2.1-7.83-4.053C39.859,292.7,40.068,189.129,40.013,85.55Z" transform="translate(-39.983 -85.55)" fill="#c68315"/>
|
||||
</g>
|
||||
<g id="_e2910dff" data-name="#e2910dff" transform="translate(292.385 91.806)">
|
||||
<path id="Path_10" data-name="Path 10" d="M296.066,188.786Q393.021,137.31,489.833,85.57c-.088,103.612.176,207.236-.132,310.837-2.059.947-4.108,1.916-6.156,2.852-.3-1.971-.584-3.954-.7-5.936q0-147.093.011-294.218a127.8,127.8,0,0,0-14.394,7.291C411,137.112,353.379,167.53,296,198.389,295.989,195.185,296,191.991,296.066,188.786Z" transform="translate(-264.822 -85.57)" fill="#e2910d"/>
|
||||
<path id="Path_11" data-name="Path 11" d="M277.58,185.348c.914-.187,2.742-.551,3.667-.738q.017,137,0,274a119.414,119.414,0,0,1-13.557,1.586c2.709-.529,5.385-1.255,8.073-1.916q.2-128.921.055-257.842C276,195.414,274.849,189.907,277.58,185.348Z" transform="translate(-267.69 -75.535)" fill="#e2910d"/>
|
||||
<path id="Path_12" data-name="Path 12" d="M269.01,451.011c4-.727,8.062-.958,12.1-1.311-.044,7.346.1,14.7-.1,22.06a73.568,73.568,0,0,1-8.965,2.1c1.211-.9,2.4-1.839,3.579-2.775.1-6.729.143-13.458-.077-20.187C273.371,450.922,271.191,450.944,269.01,451.011Z" transform="translate(-267.556 -48.675)" fill="#e2910d"/>
|
||||
</g>
|
||||
<g id="_f8a928ff" data-name="#f8a928ff" transform="translate(49.565 101.982)">
|
||||
<path id="Path_13" data-name="Path 13" d="M47.408,111.539c-.088-5.573-.066-11.156.231-16.729,5.65,2.808,11.156,5.9,16.751,8.822-.43,46.685-.055,93.37-.176,140.055-.033,54.912.055,109.824-.066,164.736-5.716-2.863-11.388-5.859-16.938-9.031.485-18.844.077-37.709.209-56.564Q47.4,227.189,47.408,111.539Z" transform="translate(-47.21 -94.81)" fill="#f8a928"/>
|
||||
<path id="Path_14" data-name="Path 14" d="M468.456,105.151a127.8,127.8,0,0,1,14.394-7.291q-.05,147.109-.011,294.218c.121,1.982.408,3.965.7,5.936l.055.385q-93.833,49.873-187.577,99.945-.083-150.611-.022-301.2c57.379-30.859,115-61.278,172.456-91.993m-9.141,41.718q-70.242,37.071-140.419,74.3a9.162,9.162,0,0,0-5.253,8.932c-.011,17.7-.088,35.4.033,53.095a8.814,8.814,0,0,0,8.689,8.855c3.568-.121,6.564-2.313,9.659-3.855q67.318-35.65,134.659-71.322a9.319,9.319,0,0,0,5.507-8.756c-.022-18.018.154-36.046-.088-54.064C472.058,147.926,464.58,143.741,459.315,146.869Z" transform="translate(-22.002 -94.501)" fill="#f8a928"/>
|
||||
<path id="Path_15" data-name="Path 15" d="M68.09,105.61c47.2,25.253,94.5,50.3,141.707,75.54,7.048,3.722,14,7.643,21.2,11.057q.066,152.66,0,305.32-81.625-43.5-163.238-87.06c.231-64.02.022-128.04.1-192.06C68.024,180.808,67.573,143.2,68.09,105.61Z" transform="translate(-45.128 -93.716)" fill="#f8a928"/>
|
||||
<path id="Path_16" data-name="Path 16" d="M232.045,184.73c2.214.385,4.427.76,6.652,1.079.22,91.134.055,182.269.1,273.4,1.861.132,3.711.253,5.573.374.363-90.98.044-181.971.176-272.963,12.236,1.244,24.5.308,36.652-1.289-2.731,4.559-1.575,10.066-1.762,15.088q-.033,128.921-.055,257.842c-2.687.661-5.363,1.388-8.073,1.916-13.073,1.3-26.278.452-39.251-1.355q-.149-137.049-.011-274.1m23.48,30.54a9.061,9.061,0,0,0-5.9,9.328c.033,54-.066,108,.055,161.994-.242,5.551,5.694,10.088,11,8.469,4.251-1.013,6.938-5.385,6.564-9.637-.033-53.965.077-107.93-.055-161.883.242-5.826-6.245-10.419-11.663-8.271m-.044,189.438a8.733,8.733,0,0,0-5.8,8.2q-.165,13.315.011,26.641c-.209,5.782,6.278,10.308,11.652,8.172a9.075,9.075,0,0,0,5.892-9.35c-.011-8.491.1-16.982-.044-25.463C267.4,407.1,260.889,402.539,255.481,404.708Z" transform="translate(-28.488 -85.699)" fill="#f8a928"/>
|
||||
<path id="Path_17" data-name="Path 17" d="M232.011,449.63a214.472,214.472,0,0,0,40.749,1.388c2.181-.066,4.361-.088,6.542-.11.22,6.729.176,13.458.077,20.187-1.178.936-2.368,1.872-3.579,2.775-10.242,2.335-20.958,2.126-31.344.936.066-7.775.407-15.573-.363-23.326-1.652-.319-3.293-.65-4.934-.969-.4,6.09-.573,12.2-.374,18.3a12.568,12.568,0,0,0,1.388,5.33c-2.709-.815-5.441-1.553-8.15-2.346Q231.973,460.715,232.011,449.63Z" transform="translate(-28.487 -58.859)" fill="#f8a928"/>
|
||||
</g>
|
||||
<g id="_fabf5dff" data-name="#fabf5dff" transform="translate(66.504 110.804)">
|
||||
<path id="Path_18" data-name="Path 18" d="M62.832,102.82q2.907,1.5,5.782,3.073c-.518,37.588-.066,75.2-.231,112.8-.077,64.02.132,128.04-.1,192.06-1.883-1-3.789-1.993-5.694-2.974v-.165c.121-54.912.033-109.824.066-164.736C62.777,196.19,62.4,149.505,62.832,102.82Z" transform="translate(-62.59 -102.82)" fill="#fabf5d"/>
|
||||
</g>
|
||||
<g id="_d9d9d9ff" data-name="#d9d9d9ff" transform="translate(358.794 176.74)">
|
||||
<path id="Path_19" data-name="Path 19" d="M327.99,228.009q61.669-32.676,123.359-65.319c-.033,11.388.066,22.775-.055,34.163-1.674.881-3.337,1.773-4.978,2.72-.154-9.78.187-19.559-.2-29.328-39.515,20.441-78.557,41.8-118.106,62.181C328,230.95,328,229.485,327.99,228.009Z" transform="translate(-327.99 -162.69)" fill="#d9d9d9"/>
|
||||
</g>
|
||||
<g id="_ffffffff" data-name="#ffffffff" transform="translate(358.801 184.295)">
|
||||
<path id="Path_20" data-name="Path 20" d="M328.011,231.731c39.548-20.385,78.59-41.74,118.106-62.181.385,9.769.044,19.548.2,29.328Q387.241,230.365,328,261.554C328.011,251.621,327.978,241.676,328.011,231.731Z" transform="translate(-327.996 -169.55)" fill="#fff"/>
|
||||
</g>
|
||||
<g id="_f8ba55ff" data-name="#f8ba55ff" transform="translate(259.775 202.092)">
|
||||
<path id="Path_21" data-name="Path 21" d="M238.08,185.71c1.949.165,3.9.33,5.848.485v.33c-.132,90.991.187,181.983-.176,272.963-1.861-.121-3.711-.242-5.573-.374C238.135,367.979,238.3,276.844,238.08,185.71Z" transform="translate(-238.08 -185.71)" fill="#f8ba55"/>
|
||||
<path id="Path_22" data-name="Path 22" d="M238.168,468.734c-.2-6.1-.022-12.214.374-18.3,1.641.319,3.282.65,4.934.969.771,7.753.43,15.551.363,23.326l-4.284-.661A12.568,12.568,0,0,1,238.168,468.734Z" transform="translate(-238.079 -158.888)" fill="#f8ba55"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 12 KiB |
@@ -1,75 +1,75 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:element name="ComicInfo" nillable="true" type="ComicInfo" />
|
||||
<xs:element name="ComicInfo" nillable="true" type="ComicInfo"/>
|
||||
<xs:complexType name="ComicInfo">
|
||||
<xs:sequence>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Title" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Series" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Number" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Count" type="xs:int" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Volume" type="xs:int" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="AlternateSeries" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="AlternateNumber" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="AlternateCount" type="xs:int" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Summary" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Notes" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Year" type="xs:int" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Month" type="xs:int" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Writer" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Penciller" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Inker" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Colorist" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Letterer" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="CoverArtist" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Editor" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Publisher" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Imprint" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Genre" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Web" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="0" name="PageCount" type="xs:int" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="LanguageISO" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Format" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="BlackAndWhite" type="YesNo" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="Manga" type="YesNo" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="Pages" type="ArrayOfComicPageInfo" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Title" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Series" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Number" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Count" type="xs:int"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Volume" type="xs:int"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="AlternateSeries" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="AlternateNumber" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="AlternateCount" type="xs:int"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Summary" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Notes" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Year" type="xs:int"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Month" type="xs:int"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Writer" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Penciller" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Inker" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Colorist" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Letterer" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="CoverArtist" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Editor" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Publisher" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Imprint" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Genre" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Web" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="0" name="PageCount" type="xs:int"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="LanguageISO" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Format" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="BlackAndWhite" type="YesNo"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="Manga" type="YesNo"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="Pages" type="ArrayOfComicPageInfo"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:simpleType name="YesNo">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="Unknown" />
|
||||
<xs:enumeration value="No" />
|
||||
<xs:enumeration value="Yes" />
|
||||
<xs:enumeration value="Unknown"/>
|
||||
<xs:enumeration value="No"/>
|
||||
<xs:enumeration value="Yes"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:complexType name="ArrayOfComicPageInfo">
|
||||
<xs:sequence>
|
||||
<xs:element minOccurs="0" maxOccurs="unbounded" name="Page" nillable="true" type="ComicPageInfo" />
|
||||
<xs:element minOccurs="0" maxOccurs="unbounded" name="Page" nillable="true" type="ComicPageInfo"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="ComicPageInfo">
|
||||
<xs:attribute name="Image" type="xs:int" use="required" />
|
||||
<xs:attribute default="Story" name="Type" type="ComicPageType" />
|
||||
<xs:attribute default="false" name="DoublePage" type="xs:boolean" />
|
||||
<xs:attribute default="0" name="ImageSize" type="xs:long" />
|
||||
<xs:attribute default="" name="Key" type="xs:string" />
|
||||
<xs:attribute default="-1" name="ImageWidth" type="xs:int" />
|
||||
<xs:attribute default="-1" name="ImageHeight" type="xs:int" />
|
||||
<xs:attribute name="Image" type="xs:int" use="required"/>
|
||||
<xs:attribute default="Story" name="Type" type="ComicPageType"/>
|
||||
<xs:attribute default="false" name="DoublePage" type="xs:boolean"/>
|
||||
<xs:attribute default="0" name="ImageSize" type="xs:long"/>
|
||||
<xs:attribute default="" name="Key" type="xs:string"/>
|
||||
<xs:attribute default="-1" name="ImageWidth" type="xs:int"/>
|
||||
<xs:attribute default="-1" name="ImageHeight" type="xs:int"/>
|
||||
</xs:complexType>
|
||||
<xs:simpleType name="ComicPageType">
|
||||
<xs:list>
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="FrontCover" />
|
||||
<xs:enumeration value="InnerCover" />
|
||||
<xs:enumeration value="Roundup" />
|
||||
<xs:enumeration value="Story" />
|
||||
<xs:enumeration value="Advertisement" />
|
||||
<xs:enumeration value="Editorial" />
|
||||
<xs:enumeration value="Letters" />
|
||||
<xs:enumeration value="Preview" />
|
||||
<xs:enumeration value="BackCover" />
|
||||
<xs:enumeration value="Other" />
|
||||
<xs:enumeration value="Deleted" />
|
||||
<xs:enumeration value="FrontCover"/>
|
||||
<xs:enumeration value="InnerCover"/>
|
||||
<xs:enumeration value="Roundup"/>
|
||||
<xs:enumeration value="Story"/>
|
||||
<xs:enumeration value="Advertisement"/>
|
||||
<xs:enumeration value="Editorial"/>
|
||||
<xs:enumeration value="Letters"/>
|
||||
<xs:enumeration value="Preview"/>
|
||||
<xs:enumeration value="BackCover"/>
|
||||
<xs:enumeration value="Other"/>
|
||||
<xs:enumeration value="Deleted"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:list>
|
||||
@@ -1,63 +1,63 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:element name="ComicInfo" nillable="true" type="ComicInfo" />
|
||||
<xs:element name="ComicInfo" nillable="true" type="ComicInfo"/>
|
||||
<xs:complexType name="ComicInfo">
|
||||
<xs:sequence>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Title" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Series" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Number" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Count" type="xs:int" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Volume" type="xs:int" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="AlternateSeries" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="AlternateNumber" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="AlternateCount" type="xs:int" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Summary" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Notes" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Year" type="xs:int" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Month" type="xs:int" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Day" type="xs:int" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Writer" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Penciller" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Inker" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Colorist" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Letterer" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="CoverArtist" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Editor" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Publisher" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Imprint" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Genre" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Web" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="0" name="PageCount" type="xs:int" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="LanguageISO" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Format" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="BlackAndWhite" type="YesNo" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="Manga" type="Manga" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Characters" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Teams" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Locations" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="ScanInformation" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="StoryArc" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="SeriesGroup" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="AgeRating" type="AgeRating" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="Pages" type="ArrayOfComicPageInfo" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="CommunityRating" type="Rating" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="MainCharacterOrTeam" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Review" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Title" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Series" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Number" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Count" type="xs:int"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Volume" type="xs:int"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="AlternateSeries" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="AlternateNumber" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="AlternateCount" type="xs:int"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Summary" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Notes" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Year" type="xs:int"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Month" type="xs:int"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Day" type="xs:int"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Writer" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Penciller" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Inker" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Colorist" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Letterer" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="CoverArtist" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Editor" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Publisher" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Imprint" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Genre" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Web" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="0" name="PageCount" type="xs:int"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="LanguageISO" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Format" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="BlackAndWhite" type="YesNo"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="Manga" type="Manga"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Characters" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Teams" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Locations" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="ScanInformation" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="StoryArc" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="SeriesGroup" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="AgeRating" type="AgeRating"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="Pages" type="ArrayOfComicPageInfo"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="CommunityRating" type="Rating"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="MainCharacterOrTeam" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Review" type="xs:string"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:simpleType name="YesNo">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="Unknown" />
|
||||
<xs:enumeration value="No" />
|
||||
<xs:enumeration value="Yes" />
|
||||
<xs:enumeration value="Unknown"/>
|
||||
<xs:enumeration value="No"/>
|
||||
<xs:enumeration value="Yes"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="Manga">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="Unknown" />
|
||||
<xs:enumeration value="No" />
|
||||
<xs:enumeration value="Yes" />
|
||||
<xs:enumeration value="YesAndRightToLeft" />
|
||||
<xs:enumeration value="Unknown"/>
|
||||
<xs:enumeration value="No"/>
|
||||
<xs:enumeration value="Yes"/>
|
||||
<xs:enumeration value="YesAndRightToLeft"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="Rating">
|
||||
@@ -69,53 +69,53 @@
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="AgeRating">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="Unknown" />
|
||||
<xs:enumeration value="Adults Only 18+" />
|
||||
<xs:enumeration value="Early Childhood" />
|
||||
<xs:enumeration value="Everyone" />
|
||||
<xs:enumeration value="Everyone 10+" />
|
||||
<xs:enumeration value="G" />
|
||||
<xs:enumeration value="Kids to Adults" />
|
||||
<xs:enumeration value="M" />
|
||||
<xs:enumeration value="MA15+" />
|
||||
<xs:enumeration value="Mature 17+" />
|
||||
<xs:enumeration value="PG" />
|
||||
<xs:enumeration value="R18+" />
|
||||
<xs:enumeration value="Rating Pending" />
|
||||
<xs:enumeration value="Teen" />
|
||||
<xs:enumeration value="X18+" />
|
||||
<xs:enumeration value="Unknown"/>
|
||||
<xs:enumeration value="Adults Only 18+"/>
|
||||
<xs:enumeration value="Early Childhood"/>
|
||||
<xs:enumeration value="Everyone"/>
|
||||
<xs:enumeration value="Everyone 10+"/>
|
||||
<xs:enumeration value="G"/>
|
||||
<xs:enumeration value="Kids to Adults"/>
|
||||
<xs:enumeration value="M"/>
|
||||
<xs:enumeration value="MA15+"/>
|
||||
<xs:enumeration value="Mature 17+"/>
|
||||
<xs:enumeration value="PG"/>
|
||||
<xs:enumeration value="R18+"/>
|
||||
<xs:enumeration value="Rating Pending"/>
|
||||
<xs:enumeration value="Teen"/>
|
||||
<xs:enumeration value="X18+"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:complexType name="ArrayOfComicPageInfo">
|
||||
<xs:sequence>
|
||||
<xs:element minOccurs="0" maxOccurs="unbounded" name="Page" nillable="true" type="ComicPageInfo" />
|
||||
<xs:element minOccurs="0" maxOccurs="unbounded" name="Page" nillable="true" type="ComicPageInfo"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="ComicPageInfo">
|
||||
<xs:attribute name="Image" type="xs:int" use="required" />
|
||||
<xs:attribute default="Story" name="Type" type="ComicPageType" />
|
||||
<xs:attribute default="false" name="DoublePage" type="xs:boolean" />
|
||||
<xs:attribute default="0" name="ImageSize" type="xs:long" />
|
||||
<xs:attribute default="" name="Key" type="xs:string" />
|
||||
<xs:attribute default="" name="Bookmark" type="xs:string" />
|
||||
<xs:attribute default="-1" name="ImageWidth" type="xs:int" />
|
||||
<xs:attribute default="-1" name="ImageHeight" type="xs:int" />
|
||||
<xs:attribute name="Image" type="xs:int" use="required"/>
|
||||
<xs:attribute default="Story" name="Type" type="ComicPageType"/>
|
||||
<xs:attribute default="false" name="DoublePage" type="xs:boolean"/>
|
||||
<xs:attribute default="0" name="ImageSize" type="xs:long"/>
|
||||
<xs:attribute default="" name="Key" type="xs:string"/>
|
||||
<xs:attribute default="" name="Bookmark" type="xs:string"/>
|
||||
<xs:attribute default="-1" name="ImageWidth" type="xs:int"/>
|
||||
<xs:attribute default="-1" name="ImageHeight" type="xs:int"/>
|
||||
</xs:complexType>
|
||||
<xs:simpleType name="ComicPageType">
|
||||
<xs:list>
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="FrontCover" />
|
||||
<xs:enumeration value="InnerCover" />
|
||||
<xs:enumeration value="Roundup" />
|
||||
<xs:enumeration value="Story" />
|
||||
<xs:enumeration value="Advertisement" />
|
||||
<xs:enumeration value="Editorial" />
|
||||
<xs:enumeration value="Letters" />
|
||||
<xs:enumeration value="Preview" />
|
||||
<xs:enumeration value="BackCover" />
|
||||
<xs:enumeration value="Other" />
|
||||
<xs:enumeration value="Deleted" />
|
||||
<xs:enumeration value="FrontCover"/>
|
||||
<xs:enumeration value="InnerCover"/>
|
||||
<xs:enumeration value="Roundup"/>
|
||||
<xs:enumeration value="Story"/>
|
||||
<xs:enumeration value="Advertisement"/>
|
||||
<xs:enumeration value="Editorial"/>
|
||||
<xs:enumeration value="Letters"/>
|
||||
<xs:enumeration value="Preview"/>
|
||||
<xs:enumeration value="BackCover"/>
|
||||
<xs:enumeration value="Other"/>
|
||||
<xs:enumeration value="Deleted"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:list>
|
||||
@@ -1,66 +1,73 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:element name="ComicInfo" nillable="true" type="ComicInfo" />
|
||||
<xs:element name="ComicInfo" nillable="true" type="ComicInfo"/>
|
||||
<xs:complexType name="ComicInfo">
|
||||
<xs:sequence>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Title" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Series" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Number" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Count" type="xs:int" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Volume" type="xs:int" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="AlternateSeries" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="AlternateNumber" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="AlternateCount" type="xs:int" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Summary" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Notes" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Year" type="xs:int" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Month" type="xs:int" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Day" type="xs:int" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Writer" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Penciller" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Inker" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Colorist" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Letterer" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="CoverArtist" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Editor" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Translator" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Publisher" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Imprint" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Genre" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Tags" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Web" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="0" name="PageCount" type="xs:int" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="LanguageISO" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Format" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="BlackAndWhite" type="YesNo" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="Manga" type="Manga" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Characters" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Teams" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Locations" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="ScanInformation" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="StoryArc" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="StoryArcNumber" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="SeriesGroup" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="AgeRating" type="AgeRating" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="Pages" type="ArrayOfComicPageInfo" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="CommunityRating" type="Rating" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="MainCharacterOrTeam" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Review" type="xs:string" />
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Title" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Series" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Number" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Count" type="xs:int"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Volume" type="xs:int"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="AlternateSeries" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="AlternateNumber" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="AlternateCount" type="xs:int"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Summary" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Notes" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Year" type="xs:int"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Month" type="xs:int"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Day" type="xs:int"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Writer" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Penciller" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Inker" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Colorist" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Letterer" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="CoverArtist" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Editor" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Translator" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Publisher" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Imprint" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Genre" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Tags" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Web" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="0" name="PageCount" type="xs:int"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="LanguageISO" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Format" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="BlackAndWhite" type="YesNo"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="Manga" type="Manga"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Characters" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Teams" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Locations" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="ScanInformation" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="StoryArc" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="StoryArcNumber" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="SeriesGroup" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="AgeRating" type="AgeRating"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="Pages" type="ArrayOfComicPageInfo"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" name="CommunityRating" type="Rating"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="MainCharacterOrTeam" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Review" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Added" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="Released" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="FileSize" type="xs:int"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="FileModifiedTime" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="FileCreationTime" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="BookPrice" type="xs:string"/>
|
||||
<xs:element minOccurs="0" maxOccurs="1" default="" name="CustomValuesStore" type="xs:string"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:simpleType name="YesNo">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="Unknown" />
|
||||
<xs:enumeration value="No" />
|
||||
<xs:enumeration value="Yes" />
|
||||
<xs:enumeration value="Unknown"/>
|
||||
<xs:enumeration value="No"/>
|
||||
<xs:enumeration value="Yes"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="Manga">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="Unknown" />
|
||||
<xs:enumeration value="No" />
|
||||
<xs:enumeration value="Yes" />
|
||||
<xs:enumeration value="YesAndRightToLeft" />
|
||||
<xs:enumeration value="Unknown"/>
|
||||
<xs:enumeration value="No"/>
|
||||
<xs:enumeration value="Yes"/>
|
||||
<xs:enumeration value="YesAndRightToLeft"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="Rating">
|
||||
@@ -72,53 +79,53 @@
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="AgeRating">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="Unknown" />
|
||||
<xs:enumeration value="Adults Only 18+" />
|
||||
<xs:enumeration value="Early Childhood" />
|
||||
<xs:enumeration value="Everyone" />
|
||||
<xs:enumeration value="Everyone 10+" />
|
||||
<xs:enumeration value="G" />
|
||||
<xs:enumeration value="Kids to Adults" />
|
||||
<xs:enumeration value="M" />
|
||||
<xs:enumeration value="MA15+" />
|
||||
<xs:enumeration value="Mature 17+" />
|
||||
<xs:enumeration value="PG" />
|
||||
<xs:enumeration value="R18+" />
|
||||
<xs:enumeration value="Rating Pending" />
|
||||
<xs:enumeration value="Teen" />
|
||||
<xs:enumeration value="X18+" />
|
||||
<xs:enumeration value="Unknown"/>
|
||||
<xs:enumeration value="Adults Only 18+"/>
|
||||
<xs:enumeration value="Early Childhood"/>
|
||||
<xs:enumeration value="Everyone"/>
|
||||
<xs:enumeration value="Everyone 10+"/>
|
||||
<xs:enumeration value="G"/>
|
||||
<xs:enumeration value="Kids to Adults"/>
|
||||
<xs:enumeration value="M"/>
|
||||
<xs:enumeration value="MA15+"/>
|
||||
<xs:enumeration value="Mature 17+"/>
|
||||
<xs:enumeration value="PG"/>
|
||||
<xs:enumeration value="R18+"/>
|
||||
<xs:enumeration value="Rating Pending"/>
|
||||
<xs:enumeration value="Teen"/>
|
||||
<xs:enumeration value="X18+"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:complexType name="ArrayOfComicPageInfo">
|
||||
<xs:sequence>
|
||||
<xs:element minOccurs="0" maxOccurs="unbounded" name="Page" nillable="true" type="ComicPageInfo" />
|
||||
<xs:element minOccurs="0" maxOccurs="unbounded" name="Page" nillable="true" type="ComicPageInfo"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="ComicPageInfo">
|
||||
<xs:attribute name="Image" type="xs:int" use="required" />
|
||||
<xs:attribute default="Story" name="Type" type="ComicPageType" />
|
||||
<xs:attribute default="false" name="DoublePage" type="xs:boolean" />
|
||||
<xs:attribute default="0" name="ImageSize" type="xs:long" />
|
||||
<xs:attribute default="" name="Key" type="xs:string" />
|
||||
<xs:attribute default="" name="Bookmark" type="xs:string" />
|
||||
<xs:attribute default="-1" name="ImageWidth" type="xs:int" />
|
||||
<xs:attribute default="-1" name="ImageHeight" type="xs:int" />
|
||||
<xs:attribute name="Image" type="xs:int" use="required"/>
|
||||
<xs:attribute default="Story" name="Type" type="ComicPageType"/>
|
||||
<xs:attribute default="false" name="DoublePage" type="xs:boolean"/>
|
||||
<xs:attribute default="0" name="ImageSize" type="xs:long"/>
|
||||
<xs:attribute default="" name="Key" type="xs:string"/>
|
||||
<xs:attribute default="" name="Bookmark" type="xs:string"/>
|
||||
<xs:attribute default="-1" name="ImageWidth" type="xs:int"/>
|
||||
<xs:attribute default="-1" name="ImageHeight" type="xs:int"/>
|
||||
</xs:complexType>
|
||||
<xs:simpleType name="ComicPageType">
|
||||
<xs:list>
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="FrontCover" />
|
||||
<xs:enumeration value="InnerCover" />
|
||||
<xs:enumeration value="Roundup" />
|
||||
<xs:enumeration value="Story" />
|
||||
<xs:enumeration value="Advertisement" />
|
||||
<xs:enumeration value="Editorial" />
|
||||
<xs:enumeration value="Letters" />
|
||||
<xs:enumeration value="Preview" />
|
||||
<xs:enumeration value="BackCover" />
|
||||
<xs:enumeration value="Other" />
|
||||
<xs:enumeration value="Deleted" />
|
||||
<xs:enumeration value="FrontCover"/>
|
||||
<xs:enumeration value="InnerCover"/>
|
||||
<xs:enumeration value="Roundup"/>
|
||||
<xs:enumeration value="Story"/>
|
||||
<xs:enumeration value="Advertisement"/>
|
||||
<xs:enumeration value="Editorial"/>
|
||||
<xs:enumeration value="Letters"/>
|
||||
<xs:enumeration value="Preview"/>
|
||||
<xs:enumeration value="BackCover"/>
|
||||
<xs:enumeration value="Other"/>
|
||||
<xs:enumeration value="Deleted"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:list>
|
||||
@@ -1,4 +0,0 @@
|
||||
from .helper import *
|
||||
from .comicinfo import *
|
||||
|
||||
__version__ = "3.0.1"
|
||||
@@ -1,44 +0,0 @@
|
||||
"""
|
||||
Refer:
|
||||
- https://github.com/comictagger/comictagger
|
||||
- https://github.com/Kussie/ComicInfoStandard
|
||||
- https://github.com/anansi-project/comicinfo
|
||||
"""
|
||||
|
||||
KEYS_STRING = [
|
||||
'Title', 'Series', 'Number', 'AlternateSeries', 'AlternateNumber',
|
||||
'Summary', 'Notes', 'Writer', 'Penciller', 'Inker', 'Colorist',
|
||||
'Letterer', 'CoverArtist', 'Editor', 'Publisher', 'Imprint', 'Genre',
|
||||
'Web', 'Characters', 'Teams', 'Locations', 'ScanInformation',
|
||||
'StoryArc', 'SeriesGroup', 'CommunityRating'
|
||||
]
|
||||
|
||||
KEYS_INT = [
|
||||
'Count', 'Volume', 'AlternateCount', 'Year', 'Month', 'Day', 'PageCount'
|
||||
]
|
||||
|
||||
KEYS_SPECIAL = [
|
||||
'BlackAndWhite', 'Manga', 'AgeRating', 'Pages', 'LanguageISO', 'Format', 'ESN'
|
||||
]
|
||||
|
||||
KEYS_AGE = [
|
||||
'Adults Only 18+', 'Early Childhood', 'Everyone', 'Everyone 10+',
|
||||
'G', 'Kids to Adults', 'M', 'MA 15+', 'Mature 17+', 'PG', 'R18+',
|
||||
'Rating Pending', 'Teen', 'X18+', 'Rating Pending'
|
||||
]
|
||||
|
||||
KEYS_FORMAT = [
|
||||
'1 Shot', '1/2', '1-Shot', 'Annotation', 'Annotations',
|
||||
'Annual', 'Anthology', 'B&W', 'B/W', 'B&&W', 'Black & White', 'Box Set',
|
||||
'Box-Set', 'Crossover', "Director's Cut", 'Epilogue', 'Event', 'FCBD',
|
||||
'Flyer', 'Giant', 'Giant Size', 'Giant-Size', 'Graphic Novel', 'Hardcover',
|
||||
'Hard-Cover', 'King', 'King Size', 'King-Size', 'Limited Series', 'Magazine',
|
||||
'NSFW', 'One Shot', 'One-Shot', 'Point 1', 'Preview', 'Prologue', 'Reference',
|
||||
'Review', 'Reviewed', 'Scanlation', 'Script', 'Series', 'Sketch', 'Special',
|
||||
'TPB', 'Trade Paper Back', 'WebComic', 'Web Comic', 'Year 1', 'Year One'
|
||||
]
|
||||
|
||||
KEYS_PAGE_TYPE = [
|
||||
'FrontCover', 'InnerCover', 'Roundup', 'Story', 'Advertisment',
|
||||
'Editorial', 'Letters', 'Preview', 'BackCover', 'Other', 'Deleted'
|
||||
]
|
||||
@@ -1,14 +0,0 @@
|
||||
class PyCBZHelperException(Exception):
|
||||
"""Exceptions used by pycbzhelper."""
|
||||
|
||||
|
||||
class InvalidKeyValue(PyCBZHelperException):
|
||||
"""The key value is invalid."""
|
||||
|
||||
|
||||
class MissingPageFile(PyCBZHelperException):
|
||||
"""No page available."""
|
||||
|
||||
|
||||
class InvalidFilePermission(PyCBZHelperException):
|
||||
"""Unable to delete existing file."""
|
||||
@@ -1,120 +0,0 @@
|
||||
import os
|
||||
import shutil
|
||||
import zipfile
|
||||
|
||||
from json2xml import json2xml
|
||||
from langcodes import Language
|
||||
from PIL import Image
|
||||
|
||||
from pycbzhelper.comicinfo import KEYS_STRING, KEYS_INT, KEYS_SPECIAL, KEYS_AGE, KEYS_FORMAT, KEYS_PAGE_TYPE
|
||||
from pycbzhelper.exceptions import InvalidKeyValue, MissingPageFile, InvalidFilePermission
|
||||
from pycbzhelper.utils import get_key_value, delete_none, slugify
|
||||
|
||||
|
||||
class Helper:
|
||||
|
||||
def __init__(self, kwargs):
|
||||
self._files = []
|
||||
self.metadata = self._get_metadata(kwargs)
|
||||
|
||||
def _get_metadata(self, kwargs) -> str:
|
||||
# NOTE: Check metadata
|
||||
for key in KEYS_STRING:
|
||||
if kwargs.get(key) and not isinstance(kwargs.get(key), str):
|
||||
raise InvalidKeyValue(f"ERROR: Key must be string: {key}")
|
||||
|
||||
for key in KEYS_INT:
|
||||
if kwargs.get(key) and not isinstance(kwargs.get(key), int):
|
||||
raise InvalidKeyValue(f"ERROR: Key must be integer: {key}")
|
||||
|
||||
for key in KEYS_SPECIAL:
|
||||
if kwargs.get(key):
|
||||
if key == 'BlackAndWhite' and get_key_value(kwargs.get(key)) not in ['Yes', 'No']:
|
||||
raise InvalidKeyValue(f"ERROR: Key must be boolean: {key}")
|
||||
elif key == 'Manga' and get_key_value(kwargs.get(key)) not in ['YesAndRightToLeft', 'Yes', 'No']:
|
||||
raise InvalidKeyValue(f"ERROR: Key must be boolean or special boolean: {key}")
|
||||
elif key == 'AgeRating' and kwargs.get(key) not in KEYS_AGE:
|
||||
raise InvalidKeyValue(f"ERROR: Key must be special age: {key}")
|
||||
elif key == 'LanguageISO' and not Language.get(kwargs.get(key)).is_valid():
|
||||
raise InvalidKeyValue(f"ERROR: Key must be ISO language: {key}")
|
||||
elif key == 'Format' and kwargs.get(key) not in KEYS_FORMAT:
|
||||
raise InvalidKeyValue(f"ERROR: Key must be special format: {key}")
|
||||
elif key == 'Pages':
|
||||
if isinstance(kwargs.get(key), list):
|
||||
for page in kwargs.get(key):
|
||||
if not page.get('File') or not isinstance(page.get('File'), str) or not os.path.exists(page.get('File')):
|
||||
raise InvalidKeyValue(f"ERROR: Key must be existing string path: {key}")
|
||||
if page.get('Type') and not page.get('Type') in KEYS_PAGE_TYPE:
|
||||
raise InvalidKeyValue("ERROR: Key must be special type: Type")
|
||||
if page.get('DoublePage') and get_key_value(page.get('DoublePage')) not in ['Yes', 'No']:
|
||||
raise InvalidKeyValue("ERROR: Key must be boolean: DoublePage")
|
||||
else:
|
||||
raise InvalidKeyValue(f"ERROR: Key must be a list: {key}")
|
||||
|
||||
# NOTE: Set metadata
|
||||
pages = []
|
||||
if kwargs.get('Pages'):
|
||||
# [{'File': 'FILE_PATH', 'Type': 'FrontCover', 'DoublePage': False}]
|
||||
pages.append(" <Pages>")
|
||||
kwargs['PageCount'] = len(kwargs.get('Pages'))
|
||||
for i in range(kwargs.get('PageCount')):
|
||||
page = kwargs.get('Pages')[i]
|
||||
properties = Image.open(page['File'])
|
||||
self._files.append(page['File'])
|
||||
if not page.get('Type'):
|
||||
page['Type'] = 'FrontCover' if i == 0 else 'Story'
|
||||
|
||||
item = ' <Page DoublePage="True"' if get_key_value(
|
||||
page.get('DoublePage', False)) == 'Yes' else ' <Page'
|
||||
pages.append(
|
||||
item + ' Image="{image}" ImageHeight="{height}" ImageSize="{size}" ImageWidth="{width}" Type="{type}" />'.format(
|
||||
double="False" if get_key_value(page.get('DoublePage', False)) == 'No' else "True",
|
||||
image=i,
|
||||
height=properties.height,
|
||||
size=len(properties.fp.read()),
|
||||
width=properties.width,
|
||||
type=page['Type']
|
||||
)
|
||||
)
|
||||
pages.append(" </Pages>")
|
||||
del kwargs['Pages']
|
||||
pages.append("</ComicInfo>")
|
||||
|
||||
json_data = {}
|
||||
for key in KEYS_STRING + KEYS_INT + KEYS_SPECIAL:
|
||||
json_data[key] = get_key_value(kwargs.get(key))
|
||||
|
||||
xml_data = json2xml.Json2xml(delete_none(json_data), wrapper="ComicInfo", pretty=True, attr_type=False).to_xml()
|
||||
if not xml_data:
|
||||
xml_data = '\n'.join(['<?xml version="1.0" ?>', '<ComicInfo>', '</ComicInfo>'])
|
||||
print('WARNING: No metadata to create.')
|
||||
xml_data = xml_data.replace('<?xml version="1.0" ?>', '<?xml version="1.0" encoding="utf-8"?>')
|
||||
xml_data = xml_data.replace('</ComicInfo>', '\n'.join(pages))
|
||||
return xml_data.strip()
|
||||
|
||||
def save_cbz(self, path: str, file: str, clear: bool = False, replace: bool = True) -> None:
|
||||
if len(self._files) == 0:
|
||||
raise MissingPageFile('ERROR: No pages available.')
|
||||
|
||||
output = os.path.join(path, f"{slugify(file, allow_unicode=False)}.cbz")
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
if os.path.exists(output) and not replace:
|
||||
raise InvalidFilePermission('ERROR: File already exists. The replace option is not enabled.')
|
||||
elif os.path.exists(output):
|
||||
os.remove(output)
|
||||
|
||||
clear_path = []
|
||||
cbz = zipfile.ZipFile(output, 'w', compression=zipfile.ZIP_STORED)
|
||||
for file in self._files:
|
||||
if os.path.dirname(file) not in clear_path:
|
||||
clear_path.append(os.path.dirname(file))
|
||||
with open(file, mode='rb') as f:
|
||||
cbz.writestr(os.path.basename(file), data=f.read())
|
||||
cbz.writestr('ComicInfo.xml', data=self.metadata.encode('utf-8'))
|
||||
cbz.close()
|
||||
print(f"INFO: File create: {output}")
|
||||
if clear:
|
||||
for path in clear_path:
|
||||
shutil.rmtree(path)
|
||||
print(f"INFO: Folder deleted: {path}")
|
||||
@@ -1,47 +0,0 @@
|
||||
from __future__ import annotations
|
||||
from typing import Union
|
||||
|
||||
import unicodedata
|
||||
|
||||
|
||||
def get_key_value(_value) -> str:
|
||||
if isinstance(_value, str):
|
||||
if _value in ['YesAndRightToLeft', 'Yes', 'No']:
|
||||
return _value
|
||||
elif isinstance(_value, bool):
|
||||
return 'Yes' if _value else 'No'
|
||||
return _value
|
||||
|
||||
|
||||
def delete_none(_dict: dict) -> dict:
|
||||
"""Delete None values recursively from all of the dictionaries, tuples, lists, sets"""
|
||||
if isinstance(_dict, dict):
|
||||
for key, value in list(_dict.items()):
|
||||
if isinstance(value, (list, dict, tuple, set)):
|
||||
_dict[key] = delete_none(value)
|
||||
elif value is None or key is None:
|
||||
del _dict[key]
|
||||
if value == {}:
|
||||
del _dict[key]
|
||||
|
||||
elif isinstance(_dict, (list, set, tuple)):
|
||||
_dict = type(_dict)(delete_none(item) for item in _dict if item is not None)
|
||||
return _dict
|
||||
|
||||
|
||||
def slugify(value: Union[str, int], allow_unicode: bool = False) -> str:
|
||||
"""
|
||||
Taken from https://github.com/django/django/blob/master/django/utils/text.py
|
||||
Convert to ASCII if 'allow_unicode' is False. Convert spaces or repeated
|
||||
dashes to single dashes. Remove characters that aren't alphanumerics,
|
||||
underscores, or hyphens. Convert to lowercase. Also strip leading and
|
||||
trailing whitespace, dashes, and underscores.
|
||||
"""
|
||||
value = str(value)
|
||||
if allow_unicode:
|
||||
value = unicodedata.normalize('NFKC', value)
|
||||
else:
|
||||
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii')
|
||||
# value = re.sub(r'[^\w\s-]', '', value.lower())
|
||||
# return re.sub(r'[-\s]+', '-', value).strip('-_')
|
||||
return value
|
||||
@@ -0,0 +1,80 @@
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[tool.poetry]
|
||||
name = "cbz"
|
||||
version = "4.0.0"
|
||||
description = "Modern Python library for creating, manipulating and viewing comics in CBZ, CBR and PDF formats."
|
||||
license = "MIT"
|
||||
authors = ["hyugogirubato <65763543+hyugogirubato@users.noreply.github.com>"]
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/hyugogirubato/cbz"
|
||||
keywords = [
|
||||
"python",
|
||||
"cbz",
|
||||
"cbr",
|
||||
"pdf",
|
||||
"ebooks",
|
||||
"manga",
|
||||
"comics",
|
||||
"webtoons"
|
||||
]
|
||||
classifiers = [
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Intended Audience :: Developers",
|
||||
"Intended Audience :: End Users/Desktop",
|
||||
"Natural Language :: English",
|
||||
"Operating System :: OS Independent",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Programming Language :: Python :: 3.13",
|
||||
"Topic :: Utilities",
|
||||
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||
"Typing :: Typed",
|
||||
]
|
||||
include = [
|
||||
{ path = "CHANGELOG.md", format = "sdist" },
|
||||
{ path = "README.md", format = "sdist" },
|
||||
{ path = "LICENSE", format = "sdist" },
|
||||
]
|
||||
|
||||
[tool.poetry.urls]
|
||||
"Issues" = "https://github.com/hyugogirubato/cbz/issues"
|
||||
"Changelog" = "https://github.com/hyugogirubato/cbz/blob/main/CHANGELOG.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.9,<4.0"
|
||||
langcodes = ">=3.4.0"
|
||||
Pillow = ">=10.4.0"
|
||||
pypdf = ">=5.7.0"
|
||||
rarfile = ">=4.2"
|
||||
xmltodict = ">=0.14.2"
|
||||
pillow-avif-plugin = { version = ">=1.5.2", optional = true }
|
||||
pillow-jxl-plugin = { version = ">=1.3.4", optional = true }
|
||||
|
||||
[tool.poetry.extras]
|
||||
pillow = ["pillow-avif-plugin", "pillow-jxl-plugin"]
|
||||
|
||||
[tool.poetry.scripts]
|
||||
cbzplayer = "cbz.__main__:main"
|
||||
|
||||
[[tool.poetry.source]]
|
||||
name = "localpypi"
|
||||
url = "https://pypi.org/simple/"
|
||||
priority = "primary"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
pytest = ">=7.4.0,<10.0.0"
|
||||
pytest-cov = ">=5.0.0"
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
testpaths = ["tests"]
|
||||
addopts = [
|
||||
"--cov=cbz",
|
||||
]
|
||||
|
||||
[certificates]
|
||||
localpypi = { cert = false }
|
||||
@@ -1,30 +0,0 @@
|
||||
"""Setup module"""
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
with open('README.md', 'r') as fh:
|
||||
LONG_DESCRIPTION = fh.read()
|
||||
|
||||
setup(
|
||||
name='pycbzhelper',
|
||||
version='3.0.1',
|
||||
description='Python library to create a cbz file with metadata.',
|
||||
long_description=LONG_DESCRIPTION,
|
||||
long_description_content_type='text/markdown',
|
||||
url='https://github.com/hyugogirubato/pycbzhelper',
|
||||
author='hyugogirubato',
|
||||
author_email='hyugogirubato@gmail.com',
|
||||
license='GNU GPLv3',
|
||||
packages=['pycbzhelper'],
|
||||
install_requires=['json2xml', 'langcodes', 'pillow'],
|
||||
classifiers=[
|
||||
'Environment :: Console',
|
||||
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
|
||||
'Operating System :: OS Independent',
|
||||
'Programming Language :: Python :: 3.4',
|
||||
'Programming Language :: Python :: 3.5',
|
||||
'Programming Language :: Python :: 3.6',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Topic :: Utilities'
|
||||
]
|
||||
)
|
||||
@@ -1,43 +0,0 @@
|
||||
import os
|
||||
|
||||
import pycbzhelper
|
||||
|
||||
if __name__ == '__main__':
|
||||
pages = []
|
||||
for i in range(11):
|
||||
pages.append({'File': os.path.join('images', f"page-{i:03d}.jpg")})
|
||||
|
||||
metadata = {
|
||||
'Title': 'T1 - Arrête de me chauffer, Nagatoro',
|
||||
'Series': 'Arrête de me chauffer, Nagatoro',
|
||||
'Number': '1',
|
||||
'Count': 8,
|
||||
'Volume': 1,
|
||||
'Summary': 'Nagatoro est en seconde. Pleine d\u2019assurance, joueuse, moqueuse, elle se d\u00e9couvre un jour un passe-temps favori : martyriser son \u201cSenpai\u201d, lyc\u00e9en de premi\u00e8re timide et mal dans sa peau. Nagatoro taquine, agace, aguiche, va parfois trop loin... mais qu\u2019a-t-elle vraiment derri\u00e8re la t\u00eate ? Et si derri\u00e8re ses moqueries elle cachait une v\u00e9ritable affection ? Et si finalement, ses farces permettaient \u00e0 Senpai de s\u2019affirmer ?',
|
||||
'Year': 2021,
|
||||
'Month': 3,
|
||||
'Day': 12,
|
||||
'Writer': 'Nanashi',
|
||||
'Inker': 'Nanashi',
|
||||
'Editor': 'Noeve Grafx',
|
||||
'Publisher': 'Noeve Grafx',
|
||||
'Imprint': 'Noeve Grafx',
|
||||
'Genre': 'Shonen',
|
||||
'Web': 'http://www.izneo.com/en/manga/shonen/arrete-de-me-chauffer-nagatoro-37560/arrete-de-me-chauffer-nagatoro-86232',
|
||||
'LanguageISO': 'fr',
|
||||
'Format': 'Preview',
|
||||
'BlackAndWhite': True,
|
||||
'Manga': 'YesAndRightToLeft',
|
||||
'AgeRating': 'Everyone 10+',
|
||||
'CommunityRating': '5.0',
|
||||
'ean': '9782490676569',
|
||||
'Pages': pages
|
||||
}
|
||||
|
||||
helper = pycbzhelper.Helper(metadata)
|
||||
helper.save_cbz(
|
||||
path=os.path.join('eBooks', 'Arrête de me chauffer, Nagatoro'),
|
||||
file='T1 - Arrête de me chauffer, Nagatoro',
|
||||
clear=False,
|
||||
replace=True
|
||||
)
|
||||
@@ -0,0 +1,53 @@
|
||||
"""Test fixtures for the CBZ library."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from cbz.comic import ComicInfo
|
||||
from cbz.constants import PageType
|
||||
from cbz.page import PageInfo
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def fixtures_dir() -> Path:
|
||||
"""Path to the test fixtures directory."""
|
||||
return Path(__file__).parent / "fixtures"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def images_dir(fixtures_dir: Path) -> Path:
|
||||
"""Path to the test images directory."""
|
||||
return fixtures_dir / "images"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_image_path(images_dir: Path) -> Path:
|
||||
"""Path to a sample test image."""
|
||||
return images_dir / "page-000.jpg"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_cbz_file(tmp_path: Path, images_dir: Path) -> Path:
|
||||
"""Create a temporary CBZ file for testing."""
|
||||
image_paths = sorted(list(images_dir.iterdir()))[:3]
|
||||
pages = [
|
||||
PageInfo.load(
|
||||
path=path,
|
||||
type=PageType.FRONT_COVER if i == 0 else PageType.STORY,
|
||||
)
|
||||
for i, path in enumerate(image_paths)
|
||||
]
|
||||
|
||||
comic = ComicInfo.from_pages(
|
||||
pages=pages,
|
||||
title="Test Comic",
|
||||
series="Test Series",
|
||||
number=1,
|
||||
volume=1,
|
||||
year=2024,
|
||||
)
|
||||
|
||||
cbz_path = tmp_path / "test_comic.cbz"
|
||||
cbz_path.write_bytes(comic.pack())
|
||||
return cbz_path
|
||||
@@ -0,0 +1,64 @@
|
||||
"""Usage example for the CBZ library."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from cbz import ComicInfo, PageInfo, PageType, Format, YesNo, Manga, AgeRating
|
||||
|
||||
PARENT = Path(__file__).parent
|
||||
|
||||
if __name__ == "__main__":
|
||||
paths = sorted((PARENT / "fixtures" / "images").iterdir())
|
||||
|
||||
# Load pages with automatic type assignment
|
||||
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 comic with metadata
|
||||
comic = ComicInfo.from_pages(
|
||||
pages=pages,
|
||||
title="T1 - Arrête de me chauffer, Nagatoro",
|
||||
series="Arrête de me chauffer, Nagatoro",
|
||||
number=1,
|
||||
count=8,
|
||||
volume=1,
|
||||
summary="Nagatoro est en seconde. Pleine d\u2019assurance, joueuse, moqueuse, elle se d\u00e9couvre un jour un passe-temps favori : martyriser son \u201cSenpai\u201d, lyc\u00e9en de premi\u00e8re timide et mal dans sa peau. Nagatoro taquine, agace, aguiche, va parfois trop loin... mais qu\u2019a-t-elle vraiment derri\u00e8re la t\u00eate ? Et si derri\u00e8re ses moqueries elle cachait une v\u00e9ritable affection ? Et si finalement, ses farces permettaient \u00e0 Senpai de s\u2019affirmer ?",
|
||||
year=2021,
|
||||
month=3,
|
||||
day=12,
|
||||
writer="Nanashi",
|
||||
inker="Nanashi",
|
||||
editor="Noeve Grafx",
|
||||
publisher="Noeve Grafx",
|
||||
imprint="Noeve Grafx",
|
||||
genre="Shonen",
|
||||
web="http://www.izneo.com/en/manga/shonen/arrete-de-me-chauffer-nagatoro-37560/arrete-de-me-chauffer-nagatoro-86232",
|
||||
language_iso="fr",
|
||||
format=Format.PREVIEW,
|
||||
black_white=YesNo.YES,
|
||||
manga=Manga.YES_AND_RIGHT_TO_LEFT,
|
||||
age_rating=AgeRating.EVERYONE_10_PLUS,
|
||||
community_rating=5,
|
||||
ean="9782490676569",
|
||||
)
|
||||
|
||||
# Use the sequence protocol
|
||||
print(f"Number of pages: {len(comic)}")
|
||||
for i, page in enumerate(comic):
|
||||
print(f" Page {i}: {page.image_width}x{page.image_height} ({page.type})")
|
||||
|
||||
# Display in the built-in reader
|
||||
comic.show()
|
||||
|
||||
# Save as CBZ
|
||||
cbz_path = PARENT / f"{comic.title}.cbz"
|
||||
comic.save(cbz_path)
|
||||
print(f"Saved: {cbz_path}")
|
||||
|
Before Width: | Height: | Size: 247 KiB After Width: | Height: | Size: 247 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 143 KiB After Width: | Height: | Size: 143 KiB |
|
Before Width: | Height: | Size: 120 KiB After Width: | Height: | Size: 120 KiB |
|
Before Width: | Height: | Size: 619 KiB After Width: | Height: | Size: 619 KiB |
|
Before Width: | Height: | Size: 592 KiB After Width: | Height: | Size: 592 KiB |
|
Before Width: | Height: | Size: 680 KiB After Width: | Height: | Size: 680 KiB |
|
Before Width: | Height: | Size: 590 KiB After Width: | Height: | Size: 590 KiB |
|
Before Width: | Height: | Size: 492 KiB After Width: | Height: | Size: 492 KiB |
|
Before Width: | Height: | Size: 479 KiB After Width: | Height: | Size: 479 KiB |
|
Before Width: | Height: | Size: 549 KiB After Width: | Height: | Size: 549 KiB |
@@ -0,0 +1,221 @@
|
||||
"""Tests for the ComicInfo class."""
|
||||
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
from cbz.comic import ComicInfo
|
||||
from cbz.constants import AgeRating, Format, Manga, PageType, YesNo
|
||||
from cbz.page import PageInfo
|
||||
|
||||
|
||||
class TestComicInfo:
|
||||
"""Tests for comic creation, loading and serialization."""
|
||||
|
||||
def test_from_pages_creation(self, images_dir: Path) -> None:
|
||||
"""Create a ComicInfo from pages."""
|
||||
image_paths = sorted(list(images_dir.iterdir()))[:3]
|
||||
pages = [
|
||||
PageInfo.load(
|
||||
path=path,
|
||||
type=PageType.FRONT_COVER if i == 0 else PageType.STORY,
|
||||
)
|
||||
for i, path in enumerate(image_paths)
|
||||
]
|
||||
|
||||
comic = ComicInfo.from_pages(
|
||||
pages=pages,
|
||||
title="Test Comic",
|
||||
series="Test Series",
|
||||
number=1,
|
||||
volume=1,
|
||||
year=2024,
|
||||
)
|
||||
|
||||
assert comic.title == "Test Comic"
|
||||
assert comic.series == "Test Series"
|
||||
assert comic.number == 1
|
||||
assert comic.volume == 1
|
||||
assert comic.year == 2024
|
||||
assert len(comic) == 3
|
||||
assert comic[0].type == PageType.FRONT_COVER
|
||||
assert comic[1].type == PageType.STORY
|
||||
|
||||
def test_from_cbz_file(self, sample_cbz_file: Path) -> None:
|
||||
"""Load from a CBZ file."""
|
||||
comic = ComicInfo.from_cbz(sample_cbz_file)
|
||||
|
||||
assert comic is not None
|
||||
assert len(comic) > 0
|
||||
assert all(isinstance(page, PageInfo) for page in comic)
|
||||
|
||||
def test_pack_cbz(self, images_dir: Path) -> None:
|
||||
"""Pack into CBZ format."""
|
||||
image_paths = sorted(list(images_dir.iterdir()))[:2]
|
||||
pages = [PageInfo.load(path=path) for path in image_paths]
|
||||
|
||||
comic = ComicInfo.from_pages(
|
||||
pages=pages,
|
||||
title="Pack Test",
|
||||
series="Test Series",
|
||||
)
|
||||
|
||||
cbz_content = comic.pack()
|
||||
assert isinstance(cbz_content, bytes)
|
||||
assert len(cbz_content) > 0
|
||||
|
||||
def test_pack_with_rename(self, images_dir: Path) -> None:
|
||||
"""Pack with sequential page renaming."""
|
||||
image_paths = sorted(list(images_dir.iterdir()))[:2]
|
||||
pages = [PageInfo.load(path=path) for path in image_paths]
|
||||
|
||||
comic = ComicInfo.from_pages(pages=pages, title="Rename Test")
|
||||
cbz_content = comic.pack(rename=True)
|
||||
|
||||
assert isinstance(cbz_content, bytes)
|
||||
assert len(cbz_content) > 0
|
||||
|
||||
def test_comic_metadata_properties(self, images_dir: Path) -> None:
|
||||
"""Verify all metadata fields."""
|
||||
image_paths = sorted(list(images_dir.iterdir()))[:1]
|
||||
pages = [PageInfo.load(path=path) for path in image_paths]
|
||||
|
||||
comic = ComicInfo.from_pages(
|
||||
pages=pages,
|
||||
title="Metadata Test",
|
||||
series="Test Series",
|
||||
number=5,
|
||||
count=10,
|
||||
volume=2,
|
||||
summary="Test summary",
|
||||
year=2023,
|
||||
month=6,
|
||||
day=15,
|
||||
writer="Test Writer",
|
||||
penciller="Test Penciller",
|
||||
inker="Test Inker",
|
||||
colorist="Test Colorist",
|
||||
letterer="Test Letterer",
|
||||
cover_artist="Test Cover Artist",
|
||||
editor="Test Editor",
|
||||
publisher="Test Publisher",
|
||||
imprint="Test Imprint",
|
||||
genre="Test Genre",
|
||||
language_iso="en",
|
||||
format=Format.SERIES,
|
||||
black_white=YesNo.NO,
|
||||
manga=Manga.YES_AND_RIGHT_TO_LEFT,
|
||||
age_rating=AgeRating.TEEN,
|
||||
community_rating=4,
|
||||
)
|
||||
|
||||
assert comic.title == "Metadata Test"
|
||||
assert comic.series == "Test Series"
|
||||
assert comic.number == 5
|
||||
assert comic.count == 10
|
||||
assert comic.volume == 2
|
||||
assert comic.summary == "Test summary"
|
||||
assert comic.year == 2023
|
||||
assert comic.month == 6
|
||||
assert comic.day == 15
|
||||
assert comic.writer == "Test Writer"
|
||||
assert comic.penciller == "Test Penciller"
|
||||
assert comic.inker == "Test Inker"
|
||||
assert comic.colorist == "Test Colorist"
|
||||
assert comic.letterer == "Test Letterer"
|
||||
assert comic.cover_artist == "Test Cover Artist"
|
||||
assert comic.editor == "Test Editor"
|
||||
assert comic.publisher == "Test Publisher"
|
||||
assert comic.imprint == "Test Imprint"
|
||||
assert comic.genre == "Test Genre"
|
||||
assert comic.language_iso == "en"
|
||||
assert comic.format == Format.SERIES
|
||||
assert comic.black_white == YesNo.NO
|
||||
assert comic.manga == Manga.YES_AND_RIGHT_TO_LEFT
|
||||
assert comic.age_rating == AgeRating.TEEN
|
||||
assert comic.community_rating == 4
|
||||
|
||||
def test_page_count_property(self, images_dir: Path) -> None:
|
||||
"""Verify page count via len()."""
|
||||
image_paths = sorted(list(images_dir.iterdir()))[:4]
|
||||
pages = [PageInfo.load(path=path) for path in image_paths]
|
||||
|
||||
comic = ComicInfo.from_pages(pages=pages, title="Count Test")
|
||||
assert len(comic) == 4
|
||||
|
||||
def test_empty_pages_list(self) -> None:
|
||||
"""Create a comic with no pages."""
|
||||
comic = ComicInfo.from_pages(pages=[], title="Empty Test")
|
||||
assert comic.title == "Empty Test"
|
||||
assert len(comic) == 0
|
||||
|
||||
def test_single_page_comic_load(self, images_dir: Path) -> None:
|
||||
"""Round-trip load of a single-page comic."""
|
||||
image_paths = sorted(list(images_dir.iterdir()))[:1]
|
||||
pages = [PageInfo.load(path=path) for path in image_paths]
|
||||
|
||||
comic = ComicInfo.from_pages(pages=pages, title="Single Page Test")
|
||||
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
temp_path = Path(temp_dir) / "single_page.cbz"
|
||||
comic.save(temp_path)
|
||||
assert temp_path.exists()
|
||||
|
||||
loaded = ComicInfo.from_cbz(temp_path)
|
||||
assert loaded.title == "Single Page Test"
|
||||
assert len(loaded) == 1
|
||||
|
||||
def test_sequence_protocol(self, images_dir: Path) -> None:
|
||||
"""Verify sequence protocol (iteration, indexing)."""
|
||||
image_paths = sorted(list(images_dir.iterdir()))[:3]
|
||||
pages = [PageInfo.load(path=path) for path in image_paths]
|
||||
|
||||
comic = ComicInfo.from_pages(pages=pages, title="Sequence Test")
|
||||
|
||||
# Iteration
|
||||
count = 0
|
||||
for page in comic:
|
||||
assert isinstance(page, PageInfo)
|
||||
count += 1
|
||||
assert count == 3
|
||||
|
||||
# Indexing
|
||||
first = comic[0]
|
||||
assert isinstance(first, PageInfo)
|
||||
last = comic[-1]
|
||||
assert isinstance(last, PageInfo)
|
||||
|
||||
# Slicing
|
||||
subset = comic[0:2]
|
||||
assert len(subset) == 2
|
||||
|
||||
# Containment
|
||||
assert first in comic
|
||||
|
||||
def test_get_info(self, images_dir: Path) -> None:
|
||||
"""Verify metadata serialization."""
|
||||
image_paths = sorted(list(images_dir.iterdir()))[:2]
|
||||
pages = [PageInfo.load(path=path) for path in image_paths]
|
||||
|
||||
comic = ComicInfo.from_pages(
|
||||
pages=pages,
|
||||
title="Info Test",
|
||||
series="Test Series",
|
||||
year=2024,
|
||||
)
|
||||
|
||||
info = comic.get_info()
|
||||
assert info["Title"] == "Info Test"
|
||||
assert info["Series"] == "Test Series"
|
||||
assert info["Year"] == 2024
|
||||
assert info["PageCount"] == 2
|
||||
assert "Pages" in info
|
||||
assert len(info["Pages"]["Page"]) == 2
|
||||
|
||||
def test_none_defaults(self) -> None:
|
||||
"""Verify optional fields default to None."""
|
||||
comic = ComicInfo.from_pages(pages=[])
|
||||
assert comic.number is None
|
||||
assert comic.count is None
|
||||
assert comic.volume is None
|
||||
assert comic.year is None
|
||||
assert comic.community_rating is None
|
||||
@@ -0,0 +1,204 @@
|
||||
"""Tests for data models."""
|
||||
|
||||
from dataclasses import fields
|
||||
|
||||
import pytest
|
||||
|
||||
from cbz.constants import (
|
||||
AgeRating,
|
||||
Format,
|
||||
LanguageISO,
|
||||
Manga,
|
||||
PageType,
|
||||
Rating,
|
||||
YesNo,
|
||||
)
|
||||
from cbz.models import ComicModel, PageModel, _get_xml_mapping
|
||||
|
||||
|
||||
class TestComicModel:
|
||||
"""Tests for the ComicModel dataclass."""
|
||||
|
||||
def test_default_values(self) -> None:
|
||||
"""Correct default values."""
|
||||
model = ComicModel()
|
||||
|
||||
assert model.title == ""
|
||||
assert model.series == ""
|
||||
assert model.number is None
|
||||
assert model.count is None
|
||||
assert model.volume is None
|
||||
assert model.year is None
|
||||
assert model.format == Format.UNKNOWN
|
||||
assert model.black_white == YesNo.UNKNOWN
|
||||
assert model.manga == Manga.UNKNOWN
|
||||
assert model.age_rating == AgeRating.UNKNOWN
|
||||
assert model.community_rating is None
|
||||
|
||||
def test_with_values(self) -> None:
|
||||
"""Creation with specific values."""
|
||||
model = ComicModel(
|
||||
title="Test Comic",
|
||||
series="Test Series",
|
||||
number=1,
|
||||
volume=1,
|
||||
year=2024,
|
||||
month=6,
|
||||
day=15,
|
||||
writer="Test Writer",
|
||||
publisher="Test Publisher",
|
||||
language_iso=LanguageISO("en"),
|
||||
format=Format.SERIES,
|
||||
black_white=YesNo.NO,
|
||||
manga=Manga.YES_AND_RIGHT_TO_LEFT,
|
||||
age_rating=AgeRating.EVERYONE,
|
||||
)
|
||||
|
||||
assert model.title == "Test Comic"
|
||||
assert model.series == "Test Series"
|
||||
assert model.number == 1
|
||||
assert model.year == 2024
|
||||
assert model.format == Format.SERIES
|
||||
assert model.manga == Manga.YES_AND_RIGHT_TO_LEFT
|
||||
|
||||
def test_enum_assignment(self) -> None:
|
||||
"""Enum assignment."""
|
||||
model = ComicModel()
|
||||
|
||||
model.format = Format.PREVIEW
|
||||
assert model.format == Format.PREVIEW
|
||||
|
||||
model.black_white = YesNo.YES
|
||||
assert model.black_white == YesNo.YES
|
||||
|
||||
model.manga = Manga.YES_AND_RIGHT_TO_LEFT
|
||||
assert model.manga == Manga.YES_AND_RIGHT_TO_LEFT
|
||||
|
||||
model.age_rating = AgeRating.TEEN
|
||||
assert model.age_rating == AgeRating.TEEN
|
||||
|
||||
def test_metadata_fields(self) -> None:
|
||||
"""Verify metadata fields."""
|
||||
model = ComicModel(
|
||||
summary="Test summary",
|
||||
notes="Test notes",
|
||||
genre="Adventure",
|
||||
web="http://example.com",
|
||||
ean="1234567890123",
|
||||
community_rating=Rating(5),
|
||||
main_character_or_team="Hero",
|
||||
characters="Hero, Villain",
|
||||
teams="Justice League",
|
||||
locations="Metropolis",
|
||||
scan_information="Scanned by Test",
|
||||
story_arc="Origin Story",
|
||||
series_group="DC Comics",
|
||||
alternate_series="Alternate Universe",
|
||||
alternate_number=2,
|
||||
alternate_count=10,
|
||||
)
|
||||
|
||||
assert model.summary == "Test summary"
|
||||
assert model.genre == "Adventure"
|
||||
assert model.community_rating == 5
|
||||
assert model.characters == "Hero, Villain"
|
||||
assert model.alternate_number == 2
|
||||
|
||||
def test_xml_mapping(self) -> None:
|
||||
"""Verify XML mapping."""
|
||||
mapping = _get_xml_mapping(ComicModel)
|
||||
assert "title" in mapping
|
||||
assert mapping["title"][0] == "Title"
|
||||
|
||||
def test_all_fields_have_xml_mapping(self) -> None:
|
||||
"""All annotated fields have an XML mapping."""
|
||||
mapping = _get_xml_mapping(ComicModel)
|
||||
for f in fields(ComicModel):
|
||||
if "xml_name" in f.metadata:
|
||||
assert f.name in mapping
|
||||
|
||||
|
||||
class TestPageModel:
|
||||
"""Tests for the PageModel dataclass."""
|
||||
|
||||
def test_default_values(self) -> None:
|
||||
"""Correct default values."""
|
||||
model = PageModel()
|
||||
|
||||
assert model.type == PageType.STORY
|
||||
assert model.double is False
|
||||
assert model.image_size == 0
|
||||
assert model.key == ""
|
||||
assert model.bookmark == ""
|
||||
assert model.image_width == 0
|
||||
assert model.image_height == 0
|
||||
|
||||
def test_with_values(self) -> None:
|
||||
"""Creation with specific values."""
|
||||
model = PageModel(
|
||||
type=PageType.FRONT_COVER,
|
||||
double=True,
|
||||
image_size=1024000,
|
||||
key="cover",
|
||||
bookmark="Chapter 1",
|
||||
image_width=800,
|
||||
image_height=1200,
|
||||
)
|
||||
|
||||
assert model.type == PageType.FRONT_COVER
|
||||
assert model.double is True
|
||||
assert model.image_size == 1024000
|
||||
assert model.key == "cover"
|
||||
assert model.bookmark == "Chapter 1"
|
||||
assert model.image_width == 800
|
||||
assert model.image_height == 1200
|
||||
|
||||
def test_all_page_types(self) -> None:
|
||||
"""All page types are valid."""
|
||||
for page_type in PageType:
|
||||
model = PageModel(type=page_type)
|
||||
assert model.type == page_type
|
||||
|
||||
def test_boolean_properties(self) -> None:
|
||||
"""Boolean double property."""
|
||||
model = PageModel()
|
||||
model.double = True
|
||||
assert model.double is True
|
||||
model.double = False
|
||||
assert model.double is False
|
||||
|
||||
|
||||
class TestRating:
|
||||
"""Tests for the Rating type."""
|
||||
|
||||
def test_valid_rating(self) -> None:
|
||||
"""Valid ratings (0-5)."""
|
||||
assert Rating(0) == 0.0
|
||||
assert Rating(2.5) == 2.5
|
||||
assert Rating(5) == 5.0
|
||||
|
||||
def test_invalid_rating(self) -> None:
|
||||
"""Invalid ratings raise ValueError."""
|
||||
with pytest.raises(ValueError):
|
||||
Rating(-1)
|
||||
with pytest.raises(ValueError):
|
||||
Rating(6)
|
||||
|
||||
|
||||
class TestLanguageISO:
|
||||
"""Tests for the LanguageISO type."""
|
||||
|
||||
def test_valid_language(self) -> None:
|
||||
"""Valid language codes."""
|
||||
assert LanguageISO("en") == "en"
|
||||
assert LanguageISO("fr") == "fr"
|
||||
assert LanguageISO("ja") == "ja"
|
||||
|
||||
def test_empty_language(self) -> None:
|
||||
"""Empty language code is allowed."""
|
||||
assert LanguageISO("") == ""
|
||||
|
||||
def test_invalid_language(self) -> None:
|
||||
"""Invalid language code raises ValueError."""
|
||||
with pytest.raises(ValueError):
|
||||
LanguageISO("zzzzzzz")
|
||||
@@ -0,0 +1,132 @@
|
||||
"""Tests for the PageInfo class."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from cbz.constants import PageType
|
||||
from cbz.exceptions import InvalidImageError
|
||||
from cbz.page import PageInfo
|
||||
|
||||
|
||||
class TestPageInfo:
|
||||
"""Tests for page loading, properties and manipulation."""
|
||||
|
||||
def test_load_from_file(self, sample_image_path: Path) -> None:
|
||||
"""Load from an image file."""
|
||||
page = PageInfo.load(path=sample_image_path)
|
||||
|
||||
assert page is not None
|
||||
assert isinstance(page.content, bytes)
|
||||
assert len(page.content) > 0
|
||||
assert page.name == sample_image_path.name
|
||||
assert page.image_width > 0
|
||||
assert page.image_height > 0
|
||||
assert page.image_size > 0
|
||||
assert page.suffix != ""
|
||||
|
||||
def test_load_with_page_type(self, sample_image_path: Path) -> None:
|
||||
"""Load with a specific page type."""
|
||||
page = PageInfo.load(path=sample_image_path, type=PageType.FRONT_COVER)
|
||||
assert page.type == PageType.FRONT_COVER
|
||||
|
||||
def test_load_with_custom_name(self, sample_image_path: Path) -> None:
|
||||
"""Load with a custom name."""
|
||||
page = PageInfo.load(path=sample_image_path, name="custom_page.jpg")
|
||||
assert page.name == "custom_page.jpg"
|
||||
|
||||
def test_page_content_property(self, sample_image_path: Path) -> None:
|
||||
"""Content property and automatic metadata extraction."""
|
||||
page = PageInfo.load(path=sample_image_path)
|
||||
original = page.content
|
||||
|
||||
assert page.content == original
|
||||
assert isinstance(page.content, bytes)
|
||||
assert page.image_width > 0
|
||||
assert page.image_height > 0
|
||||
assert page.image_size > 0
|
||||
|
||||
def test_image_metadata_extraction(self, sample_image_path: Path) -> None:
|
||||
"""Correct extraction of image metadata."""
|
||||
page = PageInfo.load(path=sample_image_path)
|
||||
|
||||
assert page.image_width > 0
|
||||
assert page.image_height > 0
|
||||
assert page.image_size > 0
|
||||
assert page.suffix != ""
|
||||
assert isinstance(page.image_width, int)
|
||||
assert isinstance(page.image_height, int)
|
||||
assert isinstance(page.image_size, int)
|
||||
|
||||
def test_multiple_image_formats(self, images_dir: Path) -> None:
|
||||
"""Load different image files."""
|
||||
image_files = list(images_dir.glob("*.jpg"))
|
||||
|
||||
if not image_files:
|
||||
pytest.skip("No image files found")
|
||||
|
||||
for image_path in image_files[:3]:
|
||||
page = PageInfo.load(path=image_path)
|
||||
|
||||
assert page is not None
|
||||
assert isinstance(page.content, bytes)
|
||||
assert len(page.content) > 0
|
||||
assert page.image_width > 0
|
||||
assert page.image_height > 0
|
||||
assert page.image_size > 0
|
||||
|
||||
def test_page_type_assignment(self, sample_image_path: Path) -> None:
|
||||
"""Assignment of all page types."""
|
||||
image_bytes = sample_image_path.read_bytes()
|
||||
for page_type in PageType:
|
||||
page = PageInfo.loads(data=image_bytes, type=page_type)
|
||||
assert page.type == page_type
|
||||
|
||||
def test_page_creation_from_bytes(self, sample_image_path: Path) -> None:
|
||||
"""Direct creation from bytes."""
|
||||
image_bytes = sample_image_path.read_bytes()
|
||||
|
||||
page = PageInfo.loads(data=image_bytes, name="test_page.jpg")
|
||||
|
||||
assert page.content == image_bytes
|
||||
assert page.name == "test_page.jpg"
|
||||
assert page.image_width > 0
|
||||
assert page.image_height > 0
|
||||
assert page.image_size > 0
|
||||
|
||||
def test_page_bookmark_property(self, sample_image_path: Path) -> None:
|
||||
"""Bookmark property."""
|
||||
page = PageInfo.load(path=sample_image_path, bookmark="Chapter 1")
|
||||
assert page.bookmark == "Chapter 1"
|
||||
|
||||
page_no_bookmark = PageInfo.load(path=sample_image_path)
|
||||
assert page_no_bookmark.bookmark == ""
|
||||
|
||||
def test_page_double_page_property(self, sample_image_path: Path) -> None:
|
||||
"""Double page property."""
|
||||
page = PageInfo.load(path=sample_image_path, double=True)
|
||||
assert page.double is True
|
||||
|
||||
page_no_double = PageInfo.load(path=sample_image_path)
|
||||
assert page_no_double.double is False
|
||||
|
||||
def test_invalid_data_raises_error(self) -> None:
|
||||
"""Invalid data raises InvalidImageError."""
|
||||
with pytest.raises(InvalidImageError):
|
||||
PageInfo.loads(data=b"not an image")
|
||||
|
||||
def test_empty_data_raises_error(self) -> None:
|
||||
"""Empty data raises InvalidImageError."""
|
||||
with pytest.raises(InvalidImageError):
|
||||
PageInfo.loads(data=b" ")
|
||||
|
||||
def test_save_and_reload(self, sample_image_path: Path, tmp_path: Path) -> None:
|
||||
"""Save and reload a page."""
|
||||
page = PageInfo.load(path=sample_image_path)
|
||||
save_path = tmp_path / "saved_page.jpg"
|
||||
page.save(save_path)
|
||||
|
||||
reloaded = PageInfo.load(path=save_path)
|
||||
assert reloaded.image_width == page.image_width
|
||||
assert reloaded.image_height == page.image_height
|
||||
assert reloaded.image_size == page.image_size
|
||||