From 19e5f10a7b9f8092f5d6060fee24227c16a36474 Mon Sep 17 00:00:00 2001 From: Mizaki Date: Fri, 4 Nov 2022 16:16:07 +0000 Subject: [PATCH] Revert "Revert passing only issue id to fetch_comic_data. Instead send issue id, volume id and issue number. This is because MU will not have the issue number from the API call. Now, if it has been parsed from the file name it will be available for use by the MU talker." This reverts commit e5e96170522e97173ef47900702aa4dfafcffb69. --- comictaggerlib/cli.py | 10 +++++----- comictaggerlib/taggerwindow.py | 15 +++++++++++---- comictalker/talkers/comicvine.py | 6 +++--- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/comictaggerlib/cli.py b/comictaggerlib/cli.py index b88134b..3d86109 100644 --- a/comictaggerlib/cli.py +++ b/comictaggerlib/cli.py @@ -31,7 +31,7 @@ from comictaggerlib.cbltransformer import CBLTransformer from comictaggerlib.filerenamer import FileRenamer, get_rename_dir from comictaggerlib.graphics import graphics_path from comictaggerlib.issueidentifier import IssueIdentifier -from comictaggerlib.resulttypes import IssueResult, MultipleMatch, OnlineMatchResults +from comictaggerlib.resulttypes import MultipleMatch, OnlineMatchResults from comictaggerlib.settings import ComicTaggerSettings from comictalker.talkerbase import ComicTalker, TalkerError @@ -39,11 +39,11 @@ logger = logging.getLogger(__name__) def actual_issue_data_fetch( - match: IssueResult, settings: ComicTaggerSettings, opts: argparse.Namespace, talker_api: ComicTalker + issue_id: int, settings: ComicTaggerSettings, opts: argparse.Namespace, talker_api: ComicTalker ) -> GenericMetadata: # now get the particular issue data try: - ct_md = talker_api.fetch_comic_data(match["issue_id"], match["volume_id"], match["issue_number"]) + ct_md = talker_api.fetch_comic_data(issue_id) except TalkerError as e: logger.exception(f"Error retrieving issue details. Save aborted.\n{e}") return GenericMetadata() @@ -110,7 +110,7 @@ def display_match_set_for_choice( # we know at this point, that the file is all good to go ca = match_set.ca md = create_local_metadata(opts, ca, settings) - ct_md = actual_issue_data_fetch(match_set.matches[int(i) - 1], settings, opts, talker_api) + ct_md = actual_issue_data_fetch(match_set.matches[int(i) - 1]["issue_id"], settings, opts, talker_api) if opts.overwrite: md = ct_md else: @@ -456,7 +456,7 @@ def process_file_cli( # we got here, so we have a single match # now get the particular issue data - ct_md = actual_issue_data_fetch(matches[0], settings, opts, talker_api) + ct_md = actual_issue_data_fetch(matches[0]["issue_id"], settings, opts, talker_api) if ct_md.is_empty: match_results.fetch_data_failures.append(str(ca.path.absolute())) return diff --git a/comictaggerlib/taggerwindow.py b/comictaggerlib/taggerwindow.py index 7f13881..dcd9d22 100644 --- a/comictaggerlib/taggerwindow.py +++ b/comictaggerlib/taggerwindow.py @@ -1075,9 +1075,16 @@ Have fun! self.form_to_metadata() try: - new_metadata = self.talker_api.fetch_comic_data( - selector.issue_id, selector.volume_id, selector.issue_number - ) + if selector.issue_id: + new_metadata = self.talker_api.fetch_comic_data(selector.issue_id) + elif selector.volume_id and selector.issue_number: + # Would this ever be needed? + new_metadata = self.talker_api.fetch_comic_data( + series_id=selector.volume_id, issue_number=selector.issue_number + ) + else: + # Only left with series? Isn't series only handled elsewhere? + new_metadata = self.talker_api.fetch_comic_data(series_id=selector.volume_id) except TalkerError as e: QtWidgets.QApplication.restoreOverrideCursor() QtWidgets.QMessageBox.critical( @@ -1677,7 +1684,7 @@ Have fun! QtWidgets.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.CursorShape.WaitCursor)) try: - ct_md = self.talker_api.fetch_comic_data(match["issue_id"], match["volume_id"], match["issue_number"]) + ct_md = self.talker_api.fetch_comic_data(match["issue_id"]) except TalkerError as e: logger.exception(f"Save aborted.\n{e}") diff --git a/comictalker/talkers/comicvine.py b/comictalker/talkers/comicvine.py index 2494025..35aa3ec 100644 --- a/comictalker/talkers/comicvine.py +++ b/comictalker/talkers/comicvine.py @@ -578,10 +578,10 @@ class ComicVineTalker(ComicTalker): def fetch_comic_data(self, issue_id: int = 0, series_id: int = 0, issue_number: str = "") -> GenericMetadata: comic_data = GenericMetadata() # TODO remove has_issues check? Enables testing. Possibly add source option to only get volume info? - if issue_id: - comic_data = self.fetch_issue_data_by_issue_id(issue_id) - elif self.static_options.has_issues and issue_number and series_id: + if self.static_options.has_issues and issue_number and series_id: comic_data = self.fetch_issue_data(series_id, issue_number) + elif issue_id: + comic_data = self.fetch_issue_data_by_issue_id(issue_id) else: # Only retrieve the volume data comic_data = self.fetch_volume_data(series_id)