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 commit is contained in:
Mizaki 2022-11-04 00:52:22 +00:00
parent b4f6820f56
commit e5e9617052
3 changed files with 12 additions and 19 deletions

View File

@ -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 MultipleMatch, OnlineMatchResults
from comictaggerlib.resulttypes import IssueResult, 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(
issue_id: int, settings: ComicTaggerSettings, opts: argparse.Namespace, talker_api: ComicTalker
match: IssueResult, settings: ComicTaggerSettings, opts: argparse.Namespace, talker_api: ComicTalker
) -> GenericMetadata:
# now get the particular issue data
try:
ct_md = talker_api.fetch_comic_data(issue_id)
ct_md = talker_api.fetch_comic_data(match["issue_id"], match["volume_id"], match["issue_number"])
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]["issue_id"], settings, opts, talker_api)
ct_md = actual_issue_data_fetch(match_set.matches[int(i) - 1], 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]["issue_id"], settings, opts, talker_api)
ct_md = actual_issue_data_fetch(matches[0], settings, opts, talker_api)
if ct_md.is_empty:
match_results.fetch_data_failures.append(str(ca.path.absolute()))
return

View File

@ -1075,16 +1075,9 @@ Have fun!
self.form_to_metadata()
try:
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)
new_metadata = self.talker_api.fetch_comic_data(
selector.issue_id, selector.volume_id, selector.issue_number
)
except TalkerError as e:
QtWidgets.QApplication.restoreOverrideCursor()
QtWidgets.QMessageBox.critical(
@ -1684,7 +1677,7 @@ Have fun!
QtWidgets.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.CursorShape.WaitCursor))
try:
ct_md = self.talker_api.fetch_comic_data(match["issue_id"])
ct_md = self.talker_api.fetch_comic_data(match["issue_id"], match["volume_id"], match["issue_number"])
except TalkerError as e:
logger.exception(f"Save aborted.\n{e}")

View File

@ -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 self.static_options.has_issues and issue_number and series_id:
comic_data = self.fetch_issue_data(series_id, issue_number)
elif issue_id:
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:
comic_data = self.fetch_issue_data(series_id, issue_number)
else:
# Only retrieve the volume data
comic_data = self.fetch_volume_data(series_id)