Fixes for quick-tag

This commit is contained in:
Timmy Welch 2024-09-12 11:51:38 -07:00
parent acb59f9e83
commit 582224abec
5 changed files with 13 additions and 13 deletions

View File

@ -416,7 +416,7 @@ class CLI:
md,
self.config.Quick_Tag__simple,
set(self.config.Quick_Tag__hash),
self.config.Quick_Tag__skip_non_exact,
self.config.Quick_Tag__exact_only,
self.config.Runtime_Options__interactive,
self.config.Quick_Tag__aggressive_filtering,
self.config.Quick_Tag__max,

View File

@ -44,7 +44,7 @@ class SettngsNS(settngs.TypedNS):
Quick_Tag__simple: bool
Quick_Tag__aggressive_filtering: bool
Quick_Tag__hash: list[comictaggerlib.quick_tag.HashType]
Quick_Tag__skip_non_exact: bool
Quick_Tag__exact_only: bool
internal__install_id: str
internal__write_tags: list[str]
@ -167,7 +167,7 @@ class Quick_Tag(typing.TypedDict):
simple: bool
aggressive_filtering: bool
hash: list[comictaggerlib.quick_tag.HashType]
skip_non_exact: bool
exact_only: bool
class internal(typing.TypedDict):

View File

@ -43,7 +43,7 @@ class Hash(TypedDict):
class Result(TypedDict):
# Mapping of domains (eg comicvine.gamespot.com) to IDs
IDList: dict[str, list[str]]
IDs: dict[str, list[str]]
Distance: int
Hash: Hash
@ -95,7 +95,7 @@ def settings(manager: settngs.Manager) -> None:
help="Pick what hashes you want to use to search (default: %(default)s)",
)
manager.add_setting(
"--skip-non-exact",
"--exact-only",
default=True,
action=argparse.BooleanOptionalAction,
help="Skip non-exact matches if we have exact matches",
@ -118,7 +118,7 @@ class QuickTag:
tags: GenericMetadata,
simple: bool,
hashes: set[HashType],
skip_non_exact: bool,
exact_only: bool,
interactive: bool,
aggressive_filtering: bool,
max_hamming_distance: int,
@ -144,7 +144,7 @@ class QuickTag:
logger.info(f"Searching with {ahash=}, {dhash=}, {phash=}")
self.output("Searching hashes")
results = self.SearchHashes(simple, max_hamming_distance, ahash, dhash, phash, skip_non_exact)
results = self.SearchHashes(simple, max_hamming_distance, ahash, dhash, phash, exact_only)
logger.debug(f"{results=}")
if simple:
@ -161,7 +161,7 @@ class QuickTag:
return self.talker.fetch_comic_data(issue_id=chosen_result.issue_id)
def SearchHashes(
self, simple: bool, max_hamming_distance: int, ahash: str, dhash: str, phash: str, skip_non_exact: bool
self, simple: bool, max_hamming_distance: int, ahash: str, dhash: str, phash: str, exact_only: bool
) -> list[SimpleResult] | list[Result]:
resp = requests.get(
@ -172,7 +172,7 @@ class QuickTag:
"ahash": ahash,
"dhash": dhash,
"phash": phash,
"skipNonExact": str(skip_non_exact),
"exactOnly": str(exact_only),
},
)
if resp.status_code != 200:
@ -191,7 +191,7 @@ class QuickTag:
results.sort(key=lambda r: r["Distance"])
all_ids = set()
for res in results:
all_ids.update(res["IDList"].get(self.domain, []))
all_ids.update(res.get("IDList", res.get("IDs", {})).get(self.domain, [])) # type: ignore[attr-defined]
self.output(f"Retrieving basic {self.talker.name} data")
# Try to do a bulk feth of basic issue data
@ -220,7 +220,7 @@ class QuickTag:
# Re-associate the md to the distance
for res in results:
for md in mds:
if md.issue_id in res["IDList"].get(self.domain, []):
if md.issue_id in res["IDs"].get(self.domain, []):
md_results.append((res["Distance"], res["Hash"], md))
return md_results

View File

@ -21,7 +21,7 @@ from urllib.parse import urlsplit
logger = logging.getLogger(__name__)
def fix_url(url: str) -> str:
def fix_url(url: str | None) -> str:
if not url:
return ""
tmp_url = urlsplit(url)

View File

@ -472,7 +472,7 @@ class ComicVineTalker(ComicTalker):
data=json.dumps(issue).encode("utf-8"),
),
],
True,
False, # The /issues/ endpoint never provides credits
)
cached_results.append(
self._map_comic_issue_to_metadata(issue, series_info[str(issue["volume"]["id"])]),