-
Notifications
You must be signed in to change notification settings - Fork 3
Add ComicInfo.xml to generated CBZ #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
hi do you know if its possible to download all the episodes of a manga? with this project? |
|
@uzi98f It depends on the manga, it is just a way to download images from shueisha's mangaplus service, so it only downloads chapter you are able to see from the android/ios app. But if you pay the subscription and configure the system to use your account (see here: hurlenko#36) you should be pretty much able to download all of them. |
l0westbob
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your recommendations, but please clean up your changes.
| from io import BytesIO | ||
| from pathlib import Path | ||
| from typing import Union | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
mloader/exporters/cbz_exporter.py
Outdated
| import logging | ||
| log = logging.getLogger(__name__) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what?
mloader/exporters/cbz_exporter.py
Outdated
|
|
||
| log.info(f"close") | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whats the reason?
|
|
||
| # Generate and write ComicInfo.xml to the archive | ||
| comicinfo_xml = self._generate_comicinfo_xml() | ||
| xml_path = Path(self.chapter_name, "ComicInfo.xml") | ||
| self.archive.writestr(xml_path.as_posix(), comicinfo_xml) | ||
|
|
||
| # Finalize archive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens with the ZIP file in a case of an error while creating the xml file?
| """ | ||
| Generate a basic ComicInfo.xml metadata file. | ||
| See: https://github.com/anansi-project/comicinfo | ||
| Returns: | ||
| str: The ComicInfo.xml content as a string. | ||
| """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, how about:
"""
Generate a basic ComicInfo.xml metadata file.
See: https://github.com/anansi-project/comicinfo
Returns:
str: The ComicInfo.xml content as a string.
Notes:
- Values are XML-escaped to ensure the output is well-formed even if
metadata contains special characters (e.g., '&', '<', '>').
- The language code is derived from the base class via _iso_language().
"""
| return f"""<?xml version="1.0" encoding="utf-8"?> | ||
| <ComicInfo> | ||
| <Series>{self.title_name}</Series> | ||
| <Number>{self.chapter_number}</Number> | ||
| <Title>{self.chapter_title}</Title> | ||
| <Writer>{self.author}</Writer> | ||
| <LanguageISO>{self._iso_language()}</LanguageISO> | ||
| <Manga>YesAndRightToLeft</Manga> | ||
| <Publisher>Shueisha</Publisher> | ||
| <Genre>Manga</Genre> | ||
| </ComicInfo> | ||
| """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thisd should be in a constant, not raw in the return
| import logging | ||
| log = logging.getLogger(__name__) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
|
|
||
| # log.info(f"chapter: {chapter}") | ||
| # log.info(f"title: {title}") | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
| self.language = title.language | ||
| self.author = title.author | ||
| self.chapter_title = chapter.sub_title | ||
| self.chapter_number = chapter.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine, but please add a new line and a comment like this above:
Add meta data
| def _iso_language(self) -> str: | ||
|
|
||
| l = Language(self.language) | ||
| if l == Language.ENGLISH: | ||
| return 'en' | ||
| elif l == Language.SPANISH: | ||
| return 'es' | ||
| elif l == Language.FRENCH: | ||
| return 'fr' | ||
| elif l == Language.INDONESIAN: | ||
| return 'id' | ||
| elif l == Language.PORTUGUESE: | ||
| return 'pt' | ||
| elif l == Language.RUSSIAN: | ||
| return 'ru' | ||
| elif l == Language.THAI: | ||
| return 'th' | ||
| elif l == Language.GERMAN: | ||
| return 'de' | ||
| elif l == Language.VIETNAMESE: | ||
| return 'vi' | ||
| else: | ||
| return 'en' | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function itself is okay but these are no go's:
- No docstring
- single character variable names -> be expressive
- why the if, elif wall of doom instead of a map?
Hello,
I would like to add the ComicInfo.xml file inside the CBZ archive to provide metadata for comic readers.
See here: https://github.com/anansi-project/comicinfo for specification.