Move issue_id to first position of fetch_comic_data as most used.

This commit is contained in:
Mizaki 2022-10-30 17:52:55 +00:00
parent 86402af8b1
commit 870dc5e9b6
5 changed files with 11 additions and 9 deletions

View File

@ -43,7 +43,7 @@ def actual_issue_data_fetch(
) -> GenericMetadata:
# now get the particular issue data
try:
ct_md = talker_api.fetch_comic_data(issue_id=issue_id)
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()
@ -382,7 +382,7 @@ def process_file_cli(
if opts.issue_id is not None:
# we were given the actual issue ID to search with
try:
ct_md = talker_api.fetch_comic_data(issue_id=opts.issue_id)
ct_md = talker_api.fetch_comic_data(opts.issue_id)
except TalkerError as e:
logger.exception(f"Error retrieving issue details. Save aborted.\n{e}")
match_results.fetch_data_failures.append(str(ca.path.absolute()))

View File

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

View File

@ -179,7 +179,7 @@ class ComicTalker:
raise NotImplementedError
# Get issue or volume information
def fetch_comic_data(self, series_id: int = 0, issue_number: str = "", issue_id: int = 0) -> GenericMetadata:
def fetch_comic_data(self, issue_id: int = 0, series_id: int = 0, issue_number: str = "") -> GenericMetadata:
"""This function is expected to handle a few possibilities:
1. Only series_id. Retrieve the SERIES/VOLUME information only.
2. series_id and issue_number. Retrieve the ISSUE information.

View File

@ -574,7 +574,7 @@ class ComicVineTalker(ComicTalker):
return self.map_cv_volume_data_to_metadata(volume_results)
# Get issue or volume information
def fetch_comic_data(self, series_id: int = 0, issue_number: str = "", issue_id: int = 0) -> GenericMetadata:
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:

View File

@ -47,7 +47,7 @@ def test_fetch_issues_by_volume(comicvine_api, comic_cache):
def test_fetch_issue_data_by_issue_id(comicvine_api, settings, mock_now, mock_version):
ct = comictalker.talkers.comicvine.ComicVineTalker()
result = ct.fetch_comic_data(issue_id=140529)
result = ct.fetch_comic_data(140529)
assert result == testing.comicvine.cv_md