Skip to content
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

Add note to MetronInfo when migrating from ComicInfo #162

Merged
merged 1 commit into from
Nov 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion metrontagger/run.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from __future__ import annotations

import sys
from datetime import datetime
from logging import getLogger
from pathlib import Path
from typing import TYPE_CHECKING

import questionary
from darkseid.comic import Comic, MetadataFormat
from darkseid.metadata import Metadata
from darkseid.metadata import Metadata, Notes
from darkseid.utils import get_recursive_filelist
from tqdm import tqdm

Expand All @@ -19,6 +20,7 @@

if TYPE_CHECKING:
from metrontagger.settings import MetronTaggerSettings
from metrontagger import __version__
from metrontagger.styles import Styles
from metrontagger.talker import Talker
from metrontagger.validate import SchemaVersion, ValidateMetadata
Expand Down Expand Up @@ -57,6 +59,15 @@ def migrate_ci_to_mi(file_list: list[Path]) -> None:
None
"""

def create_mi_note(md: Metadata) -> Metadata:
now_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S") # noqa: DTZ005
note_txt = f"Data migrated from 'ComicInfo.xml' using MetronTagger-{__version__} on {now_date}."
if md.notes is None:
md.notes = Notes(metron_info=note_txt)
elif not md.notes.metron_info:
md.notes.metron_info = note_txt
return md

msg = create_print_title("Migrating ComicInfo.xml to MetronInfo.xml:")
questionary.print(msg, style=Styles.TITLE)

Expand All @@ -66,6 +77,7 @@ def migrate_ci_to_mi(file_list: list[Path]) -> None:
MetadataFormat.METRON_INFO
):
md = comic.read_metadata(MetadataFormat.COMIC_RACK)
md = create_mi_note(md)
if comic.write_metadata(md, MetadataFormat.METRON_INFO):
questionary.print(
f"Migrated information to new MetronInfo.xml for '{comic}'",
Expand Down
Loading