Return issue id from series search and use issue id for API.

This commit is contained in:
Mizaki 2022-10-30 00:15:05 +01:00
parent 26851475ea
commit 4f42fef4fc
3 changed files with 16 additions and 7 deletions

View File

@ -30,7 +30,7 @@ from comicapi.genericmetadata import GenericMetadata
from comictaggerlib.cbltransformer import CBLTransformer
from comictaggerlib.filerenamer import FileRenamer, get_rename_dir
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
@ -38,11 +38,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["volume_id"], match["issue_number"])
ct_md = talker_api.fetch_comic_data(issue_id=issue_id)
except TalkerError as e:
logger.exception(f"Error retrieving issue details. Save aborted.\n{e}")
return GenericMetadata()
@ -109,7 +109,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:
@ -455,7 +455,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

View File

@ -1069,7 +1069,14 @@ Have fun!
self.form_to_metadata()
try:
new_metadata = self.talker_api.fetch_comic_data(selector.volume_id, selector.issue_number)
if selector.issue_id:
new_metadata = self.talker_api.fetch_comic_data(issue_id=selector.issue_id)
elif selector.volume_id and selector.issue_number:
# Would this ever be needed?
new_metadata = self.talker_api.fetch_comic_data(selector.volume_id, selector.issue_number)
else:
# Only left with series? Isn't series only handled elsewhere?
new_metadata = self.talker_api.fetch_comic_data(selector.volume_id)
except TalkerError as e:
QtWidgets.QApplication.restoreOverrideCursor()
QtWidgets.QMessageBox.critical(
@ -1669,7 +1676,7 @@ Have fun!
QtWidgets.QApplication.setOverrideCursor(QtGui.QCursor(QtCore.Qt.CursorShape.WaitCursor))
try:
ct_md = self.talker_api.fetch_comic_data(match["volume_id"], match["issue_number"])
ct_md = self.talker_api.fetch_comic_data(issue_id=match["issue_id"])
except TalkerError as e:
logger.exception(f"Save aborted.\n{e}")

View File

@ -138,6 +138,7 @@ class VolumeSelectionWindow(QtWidgets.QDialog):
self.settings = settings
self.series_name = series_name
self.issue_number = issue_number
self.issue_id: int | None = None
self.year = year
self.issue_count = issue_count
self.volume_id = 0
@ -317,6 +318,7 @@ class VolumeSelectionWindow(QtWidgets.QDialog):
if selector.result():
# we should now have a volume ID
self.issue_number = selector.issue_number
self.issue_id = selector.issue_id
self.accept()
def select_by_id(self) -> None: