diff --git a/CHANGELOG.md b/CHANGELOG.md index 1399a3c..d3b3268 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/MANIFEST.in b/MANIFEST.in index 77e9413..6b91978 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -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 diff --git a/README.md b/README.md index 955a5ec..23a8f23 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/contrib/api_template.py b/contrib/api_template.py index 7560372..63b544c 100644 --- a/contrib/api_template.py +++ b/contrib/api_template.py @@ -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 diff --git a/docs/pages/download.md b/docs/pages/download.md index e71e131..93e465f 100644 --- a/docs/pages/download.md +++ b/docs/pages/download.md @@ -7,6 +7,10 @@ └── / └── / └── / + └── 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 \ No newline at end of file diff --git a/docs/pages/index.md b/docs/pages/index.md index db1dcdc..7dbc2ac 100644 --- a/docs/pages/index.md +++ b/docs/pages/index.md @@ -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 diff --git a/mangadlp/__about__.py b/mangadlp/__about__.py index 20868fd..55e4709 100644 --- a/mangadlp/__about__.py +++ b/mangadlp/__about__.py @@ -1 +1 @@ -__version__ = "2.2.21" +__version__ = "2.3.0" diff --git a/mangadlp/metadata.py b/mangadlp/metadata.py index f0fa425..d32cc12 100644 --- a/mangadlp/metadata.py +++ b/mangadlp/metadata.py @@ -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) diff --git a/pyproject.toml b/pyproject.toml index 3ba405c..9762d3c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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",