12 Commits
Author SHA1 Message Date
hyugogirubato 871716971a release v3.4.5 2025-10-19 19:48:27 +02:00
hyugogirubato 597cb41b00 more flexible suffix check 2025-10-19 19:48:13 +02:00
hyugogirubato a489ae17fb check invalid file content 2025-10-19 19:47:52 +02:00
hyugogirubato abc69d4673 Linking content check 2025-10-19 19:47:27 +02:00
hyugogirubato 6a1111a6bb release v3.4.4 2025-09-21 10:41:42 +02:00
hyugogirubato 220f19fe46 add additional image format 2025-09-20 19:43:52 +02:00
hyugogirubato bbab9ba3b3 Merge pull request #24 from hyugogirubato/dependabot/github_actions/actions/setup-python-6
Bump actions/setup-python from 5 to 6
2025-09-17 21:20:51 +02:00
hyugogirubato 5824a8428a add thrid-party plugins licences 2025-09-17 21:19:50 +02:00
hyugogirubato 23f7e37561 load pillow extra plugins 2025-09-17 21:16:40 +02:00
hyugogirubato 5cc4732238 add pillow extra plugins 2025-09-17 21:16:27 +02:00
hyugogirubato 9d5d539311 force sort archive filenames 2025-09-17 20:48:20 +02:00
dependabot[bot] f8274ae26b Bump actions/setup-python from 5 to 6
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5 to 6.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-08 14:42:19 +00:00
8 changed files with 65 additions and 21 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v5 - uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }} - name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5 uses: actions/setup-python@v6
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
+19
View File
@@ -4,6 +4,23 @@ 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). 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).
## [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 ## [3.4.3] - 2025-08-31
### Changed ### Changed
@@ -215,6 +232,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Initial release. - Initial release.
[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.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.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.1]: https://github.com/hyugogirubato/cbz/releases/tag/v3.4.1
+2
View File
@@ -216,6 +216,8 @@ This project uses the following third-party libraries:
- **[langcodes](https://pypi.org/project/langcodes/)** - MIT License - **[langcodes](https://pypi.org/project/langcodes/)** - MIT License
- **[Pillow](https://pypi.org/project/Pillow/)** - HPND 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 - **[pypdf](https://pypi.org/project/pypdf/)** - BSD License
- **[rarfile](https://pypi.org/project/rarfile/)** - ISC License - **[rarfile](https://pypi.org/project/rarfile/)** - ISC License
- **[xmltodict](https://pypi.org/project/xmltodict/)** - MIT License - **[xmltodict](https://pypi.org/project/xmltodict/)** - MIT License
+7
View File
@@ -1,2 +1,9 @@
from .comic import ComicInfo from .comic import ComicInfo
from .page import PageInfo from .page import PageInfo
# Register optional Pillow plugins
for _plugin in ('pillow_avif', 'pillow_jxl'):
try:
__import__(_plugin)
except ImportError:
pass
+18 -12
View File
@@ -1,5 +1,6 @@
from __future__ import annotations from __future__ import annotations
import logging
import zipfile import zipfile
from datetime import datetime, timezone from datetime import datetime, timezone
@@ -156,7 +157,7 @@ class ComicInfo(ComicModel):
ComicInfo: An instance of ComicInfo. ComicInfo: An instance of ComicInfo.
""" """
pages = [] pages = []
names = archive_file.namelist() names = sorted(archive_file.namelist())
comic_info = {} comic_info = {}
if XML_NAME in names: if XML_NAME in names:
@@ -172,17 +173,22 @@ class ComicInfo(ComicModel):
pages_info = comic_info.get('Pages', {}).get('Page', []) pages_info = comic_info.get('Pages', {}).get('Page', [])
for i, name in enumerate(names): for i, name in enumerate(names):
suffix = Path(name).suffix suffix = Path(name).suffix
if suffix:
assert suffix in IMAGE_FORMAT, f'Unsupported image format: {suffix}' # Some archives may contain folders or hidden files (e.g., ".extra/" or "__MACOSX/.DS_Store")
with archive_file.open(name, 'r') as f: # that could corrupt the suffix detection and cause invalid image handling.
page_info = {} if not suffix or suffix not in IMAGE_FORMAT:
if i < len(pages_info): logging.warning(f'Skipping unsupported or invalid file: {name!r} (suffix={suffix!r})')
page_info = ComicInfo.__extract_info( continue
items=pages_info[i],
fields=PAGE_FIELDS with archive_file.open(name, 'r') as f:
) page_info = {}
page_info['name'] = Path(name).name if i < len(pages_info):
pages.append(PageInfo.loads(data=f.read(), **page_info)) page_info = ComicInfo.__extract_info(
items=pages_info[i],
fields=PAGE_FIELDS
)
page_info['name'] = Path(name).name
pages.append(PageInfo.loads(data=f.read(), **page_info))
return ComicInfo.from_pages(pages=pages, **comic) return ComicInfo.from_pages(pages=pages, **comic)
+8 -6
View File
@@ -5,12 +5,14 @@ from langcodes import Language
XML_NAME = 'ComicInfo.xml' XML_NAME = 'ComicInfo.xml'
IMAGE_FORMAT = { IMAGE_FORMAT = {
'.jpeg', '.jpg', # Joint Photographic Experts Group '.jpeg', '.jpg', # JPEG (Joint Photographic Experts Group)
'.png', # Portable Network Graphics '.png', # PNG (Portable Network Graphics)
'.gif', # Graphics Interchange Format '.gif', # GIF (Graphics Interchange Format)
'.bmp', # Bitmap Image File '.bmp', # BMP (Bitmap Image File)
'.tiff', '.tif', # Tagged Image File Format '.tiff', '.tif', # TIFF (Tagged Image File Format)
'.webp' # Web Picture Format '.webp', # WebP (Web Picture Format, by Google)
'.jxl', # JPEG XL (Next-generation JPEG format)
'.avif' # AVIF (AV1 Image File Format, based on AV1 codec)
} }
+3 -1
View File
@@ -75,6 +75,8 @@ class PageInfo(PageModel):
data = base64.b64decode(data) data = base64.b64decode(data)
if not isinstance(data, bytes): if not isinstance(data, bytes):
raise ValueError(f'Expecting Bytes or Base64 input, got {data!r}') raise ValueError(f'Expecting Bytes or Base64 input, got {data!r}')
if not data.strip():
raise ValueError(f'Empty or null data provided (length={len(data)})')
return cls(data, **kwargs) return cls(data, **kwargs)
@classmethod @classmethod
@@ -98,7 +100,7 @@ class PageInfo(PageModel):
path = Path(path) path = Path(path)
with path.open(mode='rb') as f: with path.open(mode='rb') as f:
kwargs.setdefault('name', path.name) kwargs.setdefault('name', path.name)
return cls(f.read(), **kwargs) return cls.loads(f.read(), **kwargs)
def show(self) -> None: def show(self) -> None:
""" """
+7 -1
View File
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry] [tool.poetry]
name = "cbz" name = "cbz"
version = "3.4.3" version = "3.4.5"
description = "CBZ simplifies creating, managing, and viewing comic book files in CBZ, CBR, and PDF formats, offering seamless packaging, metadata handling and built-in viewing capabilities." description = "CBZ simplifies creating, managing, and viewing comic book files in CBZ, CBR, and PDF formats, offering seamless packaging, metadata handling and built-in viewing capabilities."
license = "MIT" license = "MIT"
authors = ["hyugogirubato <65763543+hyugogirubato@users.noreply.github.com>"] authors = ["hyugogirubato <65763543+hyugogirubato@users.noreply.github.com>"]
@@ -46,6 +46,12 @@ Pillow = ">=10.4.0"
pypdf = ">=5.7.0" pypdf = ">=5.7.0"
rarfile = ">=4.2" rarfile = ">=4.2"
xmltodict = ">=0.14.2" xmltodict = ">=0.14.2"
pillow-avif-plugin = { version = ">=1.5.2", optional = true, markers = "python_version >= '3.9'" }
pillow-jxl-plugin = { version = ">=1.3.4", optional = true, markers = "python_version >= '3.9'" }
[tool.poetry.extras]
pillow = ["pillow-avif-plugin", "pillow-jxl-plugin"]
[tool.poetry.scripts] [tool.poetry.scripts]
cbzplayer = "cbz.__main__:main" cbzplayer = "cbz.__main__:main"