GithubHelp home page GithubHelp logo

hyugogirubato / cbz Goto Github PK

View Code? Open in Web Editor NEW
20.0 1.0 6.0 34.27 MB

CBZ simplifies creating, managing, and viewing comic book files in CBZ format, offering seamless packaging, metadata handling, and built-in viewing capabilities.

Home Page: https://pypi.org/project/cbz/

License: MIT License

Python 100.00%
cbz comics python ebooks manga webtoons

cbz's People

Contributors

domenicoblanco avatar flolep2607 avatar gokender avatar hyugogirubato avatar oleskiipyskun avatar piskunqa avatar rivmt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

cbz's Issues

memory error

remove please @cache from file pack function (caching objects of 50-200 megabytes is not a good idea)
if you still need a cache, then add a constructor that will remove this object from cache when deleting a class object from memory

and fix space in " . jpg" format

Incorrect ComicInfo.xml structure: Pages not corresponding to any schema

I want to create a CBZ with this structure:

Book_1.cbz
├── ComicInfo.xml
├── page-001.jpeg
└── page-002.jpeg
pages = [
    PageInfo.load(path='1.jpg', type=PageType.STORY),
    PageInfo.load(path='2.jpg', type=PageType.STORY),
]

comic = ComicInfo.from_pages(
    pages=pages,
    series='SERIE_1',
    number=1,
)

When I look at the result of the ComicInfo.xml this is what I get:

<?xml version="1.0" encoding="utf-8"?>
<ComicInfo>
	<Series>SERIE_1</Series>
	<Number>1</Number>
	<Pages>
		<Type>Story</Type>
		<ImageSize>2530</ImageSize>
		<ImageWidth>400</ImageWidth>
		<ImageHeight>300</ImageHeight>
	</Pages>
	<Pages>
		<Type>Story</Type>
		<ImageSize>2565</ImageSize>
		<ImageWidth>400</ImageWidth>
		<ImageHeight>300</ImageHeight>
	</Pages>
</ComicInfo>

However, this structure doesn't respect any schema for the ComicInfo.xml, we should have :

<?xml version="1.0" encoding="utf-8"?>  
<ComicInfo>  
    <Series>SERIE_1</Series>  
    <Number>1</Number>  
    <Pages>
	    <Page Image="1" Type="Story" ImageSize="2530" ImageWidth="400" ImageHeight="300"/>
	    <Page Image="2" Type="Story" ImageSize="2565" ImageWidth="400" ImageHeight="300"/>  
    </Pages>
</ComicInfo>

So is this an error ? Or a deliberate choice?

Error when Parsing CBZ File with Single Page/Image

Hello,

I think there is a problem when trying to read a CBZ file that has only one page/image.

This is my CBZ created by the library:

test.cbz
|_1.bmp # just 400x800 red image 
|_ComicInfo.xml

I try this and i have an error:

>>> comic = ComicInfo.from_cbz('output/test.cbz')
Traceback (most recent call last):
  File "c:\dev\test.py", line 50, in <module>
    coco = ComicInfo.from_cbz('output/test.cbz')
  File "C:\dev\.venv\lib\site-packages\cbz\comic.py", line 69, in from_cbz
    return cls.__unpack_zip(path)
  File "C:\dev\.venv\lib\site-packages\cbz\comic.py", line 166, in __unpack_zip
    items=pages_info[i],
KeyError: 0

It tries to access the first element of the list, whereas in this case it's not a list but a dict.

When I have two images, no problem, the variable pages_info is a list.

The problem comes when you parse with xmldict: if there's only one occurrence, the parser returns the element but not a list of one element.

I've seen that there's a parameter in xmldict's parse method that allows you to force the result to be a list, regardless of the number of occurrences:

comic_info = xmltodict.parse(f.read(), force_list=('Pages')).get('ComicInfo', {})

I tested it myself and it seems to work.

Add Table of Content to CBZ file

Hi
Thank you for the job done on this project.
I have a question more than an issue.
I would like to add a table of content to CBZ file and provide specific names to each page.
Is there a better way than adding an image of the ToC at the beginning of the CBZ file?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.