Skip to content

Commit

Permalink
Add note to MetronInfo when migrating from ComicInfo (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpepple authored Nov 30, 2024
1 parent 6c1ef2c commit faa48cf
Showing 1 changed file with 13 additions and 1 deletion.
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

0 comments on commit faa48cf

Please sign in to comment.