This commit is contained in:
parent
931a536860
commit
3368b18677
2 changed files with 22 additions and 8 deletions
|
@ -45,6 +45,7 @@ class MangaDLP:
|
|||
chapter_pre_hook_cmd: str = "",
|
||||
chapter_post_hook_cmd: str = "",
|
||||
cache_path: str = "",
|
||||
add_metadata: bool = True,
|
||||
) -> None:
|
||||
# init parameters
|
||||
self.url_uuid = url_uuid
|
||||
|
@ -63,6 +64,7 @@ class MangaDLP:
|
|||
self.chapter_post_hook_cmd = chapter_post_hook_cmd
|
||||
self.hook_infos: dict = {}
|
||||
self.cache_path = cache_path
|
||||
self.add_metadata = add_metadata
|
||||
|
||||
# prepare everything
|
||||
self._prepare()
|
||||
|
@ -224,14 +226,15 @@ class MangaDLP:
|
|||
continue
|
||||
|
||||
# add metadata
|
||||
try:
|
||||
metadata = self.api.create_metadata(chapter)
|
||||
write_metadata(
|
||||
chapter_path,
|
||||
{"Format": self.file_format.removeprefix("."), **metadata},
|
||||
)
|
||||
except Exception:
|
||||
log.warning(f"Can't write metadata for chapter '{chapter}'")
|
||||
if self.add_metadata:
|
||||
try:
|
||||
metadata = self.api.create_metadata(chapter)
|
||||
write_metadata(
|
||||
chapter_path,
|
||||
{"Format": self.file_format.removeprefix("."), **metadata},
|
||||
)
|
||||
except Exception:
|
||||
log.warning(f"Can't write metadata for chapter '{chapter}'")
|
||||
|
||||
# pack downloaded folder
|
||||
if self.file_format:
|
||||
|
|
|
@ -217,6 +217,15 @@ def readin_list(_ctx, _param, value) -> list:
|
|||
show_default=True,
|
||||
help="Where to store the cache-db. If no path is given, cache is disabled",
|
||||
)
|
||||
@click.option(
|
||||
"--add-metadata/--no-metadata",
|
||||
"add_metadata",
|
||||
is_flag=True,
|
||||
default=True,
|
||||
required=False,
|
||||
show_default=True,
|
||||
help="Enable/disable creation of metadata via ComicInfo.xml",
|
||||
)
|
||||
@click.pass_context
|
||||
def main(
|
||||
ctx: click.Context,
|
||||
|
@ -237,6 +246,7 @@ def main(
|
|||
hook_chapter_pre: str,
|
||||
hook_chapter_post: str,
|
||||
cache_path: str,
|
||||
add_metadata: bool,
|
||||
): # pylint: disable=too-many-locals
|
||||
"""
|
||||
Script to download mangas from various sites
|
||||
|
@ -274,6 +284,7 @@ def main(
|
|||
chapter_pre_hook_cmd=hook_chapter_pre,
|
||||
chapter_post_hook_cmd=hook_chapter_post,
|
||||
cache_path=cache_path,
|
||||
add_metadata=add_metadata,
|
||||
)
|
||||
mdlp.get_manga()
|
||||
except (KeyboardInterrupt, Exception) as exc:
|
||||
|
|
Loading…
Reference in a new issue