Skip to content

Commit

Permalink
Merge pull request #124 from openzim/upstream_changes
Browse files Browse the repository at this point in the history
Adapt to upstream changes of zimscraperlib around metadata
  • Loading branch information
benoit74 authored Dec 20, 2024
2 parents 21f752f + ba727ee commit 9b861f5
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions scraper/src/mindtouch2zim/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
RewriteResult,
ZimPath,
)
from zimscraperlib.zim import Creator
from zimscraperlib.zim import Creator, metadata
from zimscraperlib.zim.filesystem import (
validate_file_creatable,
validate_folder_writable,
Expand Down Expand Up @@ -229,18 +229,36 @@ def _run_internal(self) -> Path:

logger.debug("Configuring metadata")
creator.config_metadata(
Name=self.formatted_config.name,
Title=self.formatted_config.title,
Publisher=self.formatted_config.publisher,
Date=datetime.datetime.now(tz=datetime.UTC).date(),
Creator=self.formatted_config.creator,
Description=self.formatted_config.description,
LongDescription=self.formatted_config.long_description,
# As of 2024-09-4 all documentation is in English.
Language=context.language_iso_639_3,
Tags=self.formatted_config.tags,
Scraper=f"{NAME} v{VERSION}",
Illustration_48x48_at_1=zim_illustration.getvalue(),
metadata.StandardMetadataList(
Name=metadata.NameMetadata(self.formatted_config.name),
Title=metadata.TitleMetadata(self.formatted_config.title),
Publisher=metadata.PublisherMetadata(self.formatted_config.publisher),
Date=metadata.DateMetadata(
datetime.datetime.now(tz=datetime.UTC).date()
),
Creator=metadata.CreatorMetadata(self.formatted_config.creator),
Description=metadata.DescriptionMetadata(
self.formatted_config.description
),
LongDescription=(
metadata.LongDescriptionMetadata(
self.formatted_config.long_description
)
if self.formatted_config.long_description
else None
),
# As of 2024-09-4 all documentation is in English.
Language=metadata.LanguageMetadata(context.language_iso_639_3),
Tags=(
metadata.TagsMetadata(self.formatted_config.tags)
if self.formatted_config.tags
else None
),
Scraper=metadata.ScraperMetadata(f"{NAME} v{VERSION}"),
Illustration_48x48_at_1=metadata.DefaultIllustrationMetadata(
zim_illustration.getvalue()
),
),
)

# jinja2 environment setup
Expand Down

0 comments on commit 9b861f5

Please sign in to comment.