Skip to content

Commit

Permalink
Refactor and add some error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bpepple committed Mar 3, 2024
1 parent 3b2570d commit 7422d9b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions metrontagger/talker.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,22 @@ def _get_source_id(md: Metadata) -> tuple[InfoSource, int | None]:
lower_notes = md.notes.lower()
if "metrontagger" in lower_notes:
source = InfoSource.metron
id_ = int(md.notes.split("issue_id:")[1].strip("]"))
try:
id_ = int(md.notes.split("issue_id:")[1].strip("]"))
except ValueError:
LOGGER.error("Comic has invalid id: %s #%s", md.series.name, md.issue)
return source, id_
if "comictagger" in lower_notes:
if "metron" in lower_notes:
source = InfoSource.metron
id_ = int(md.notes.split("Issue ID")[1].strip(" ").strip("]"))
if "comic vine" in lower_notes:
elif "comic vine" in lower_notes:
source = InfoSource.comic_vine
else:
source = InfoSource.unknown
try:
id_ = int(md.notes.split("Issue ID")[1].strip(" ").strip("]"))

except ValueError:
LOGGER.error("Comic has invalid id: %s #%s", md.series.name, md.issue)
return source, id_

def _process_file(
Expand Down

0 comments on commit 7422d9b

Please sign in to comment.