update changelog/docs etc for new metadata feature
All checks were successful
ci/woodpecker/push/tests Pipeline was successful

This commit is contained in:
Ivan Schaller 2023-02-15 14:21:45 +01:00
parent d7c3d511fe
commit 4d5b0f4dee
Signed by: olofvndrhr
GPG key ID: 2A6BE07D99C8C205
9 changed files with 81 additions and 18 deletions

View file

@ -9,7 +9,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- Add support for more sites
## [2.2.21] - 2023-02-11
## [2.3.0] - 2023-02-11
### Added

View file

@ -4,7 +4,10 @@ include *.properties
include *.py
include *.txt
include *.yml
include *.xml
recursive-include contrib *.py
recursive-include mangadlp *.py
recursive-include mangadlp *.xml
recursive-include tests *.py
recursive-include tests *.xml
recursive-include tests *.txt

View file

@ -117,6 +117,7 @@ verbosity: [mutually_exclusive]
--hook-chapter-pre TEXT Commands to execute before the chapter download starts
--hook-chapter-post TEXT Commands to execute after the chapter download finished
--cache-path PATH Where to store the cache-db. If no path is given, cache is disabled
--add-metadata / --no-metadata Enable/disable creation of metadata via ComicInfo.xml [default: add-metadata]
```
## Contribution / Bugs

View file

@ -1,4 +1,5 @@
# api template for manga-dlp
from typing import Any
class YourAPI:
@ -97,21 +98,60 @@ class YourAPI:
The metadata as a dict
"""
# metadata types. have to be correct to be valid
# metadata types. have to be valid
# {key: (type, default value, valid values)}
{
"Title": str,
"Series": str,
"Number": str,
"Count": int,
"Volume": int,
"Summary": str,
"Genre": str,
"Web": str,
"PageCount": int,
"LanguageISO": str,
"Format": str,
"ScanInformation": str,
"SeriesGroup": str,
"Title": (str, None, []),
"Series": (str, None, []),
"Number": (str, None, []),
"Count": (int, None, []),
"Volume": (int, None, []),
"AlternateSeries": (str, None, []),
"AlternateNumber": (str, None, []),
"AlternateCount": (int, None, []),
"Summary": (str, None, []),
"Notes": (
str,
"Downloaded with https://github.com/olofvndrhr/manga-dlp",
[],
),
"Year": (int, None, []),
"Month": (int, None, []),
"Day": (int, None, []),
"Writer": (str, None, []),
"Colorist": (str, None, []),
"Publisher": (str, None, []),
"Genre": (str, None, []),
"Web": (str, None, []),
"PageCount": (int, None, []),
"LanguageISO": (str, None, []),
"Format": (str, None, []),
"BlackAndWhite": (str, None, ["Yes", "No", "Unknown"]),
"Manga": (str, "Yes", ["Yes", "No", "Unknown", "YesAndRightToLeft"]),
"ScanInformation": (str, None, []),
"SeriesGroup": (str, None, []),
"AgeRating": (
str,
None,
[
"Unknown",
"Adults Only 18+",
"Early Childhood",
"Everyone",
"Everyone 10+",
"G",
"Kids to Adults",
"M",
"MA15+",
"Mature 17+",
"PG",
"R18+",
"Rating Pending",
"Teen",
"X18+",
],
),
"CommunityRating": (int, None, [1, 2, 3, 4, 5]),
}
# example

View file

@ -7,6 +7,10 @@
└── <download path>/
└── <manga title>/
└── <chapter title>/
└── ComicInfo.xml (optional)
└── 001.png
└── 002.png
└── etc.
```
**Example:**
@ -167,3 +171,12 @@ chapters will be
tracked there, and the script doesn't have to check on disk if you already downloaded it.
If the option is unset (default), then no caching will be done.
## Add metadata
manga-dlp supports the creation of metadata files in the downloaded chapter.
The metadata is based on the newer [ComicRack/Anansi](https://anansi-project.github.io/docs/introduction) standard.
The default option is to add the metadata in the folder/archive with the name `ComicInfo.xml`.
If you don't want metadata, you can pass the `--no-metadata` flag.
> pdf format does not support metadata at the moment

View file

@ -115,6 +115,7 @@ verbosity: [mutually_exclusive]
--hook-chapter-pre TEXT Commands to execute before the chapter download starts
--hook-chapter-post TEXT Commands to execute after the chapter download finished
--cache-path PATH Where to store the cache-db. If no path is given, cache is disabled
--add-metadata / --no-metadata Enable/disable creation of metadata via ComicInfo.xml [default: add-metadata]
```
## Contribution / Bugs

View file

@ -1 +1 @@
__version__ = "2.2.21"
__version__ = "2.3.0"

View file

@ -4,8 +4,10 @@ from typing import Any
import xmltodict
from loguru import logger as log
METADATA_FILENAME = "ComicInfo.xml"
METADATA_TEMPLATE = Path("mangadlp/metadata/ComicInfo_v2.0.xml")
# define metadata types and valid values. an empty list means no value check
# define metadata types, defaults and valid values. an empty list means no value check
# {key: (type, default value, valid values)}
METADATA_TYPES: dict[str, tuple[type, Any, list]] = {
"Title": (str, None, []),
"Series": (str, None, []),
@ -105,7 +107,7 @@ def write_metadata(chapter_path: Path, metadata: dict) -> None:
log.warning("Can't add metadata for pdf format. Skipping")
return
metadata_file = chapter_path / "ComicInfo.xml"
metadata_file = chapter_path / METADATA_FILENAME
log.debug(f"Metadata items: {metadata}")
metadata_valid = validate_metadata(metadata)

View file

@ -30,6 +30,7 @@ dependencies = [
"loguru>=0.6.0",
"click>=8.1.3",
"click-option-group>=0.5.5",
"xmltodict>=0.13.0"
]
[project.urls]
@ -60,6 +61,8 @@ dependencies = [
"loguru>=0.6.0",
"click>=8.1.3",
"click-option-group>=0.5.5",
"xmltodict>=0.13.0",
"xmlschema>=2.2.1",
"img2pdf>=0.4.4",
"hatch>=1.6.0",
"hatchling>=1.11.0",