diff --git a/comictalker/comiccacher.py b/comictalker/comiccacher.py index 7fca137..7625edf 100644 --- a/comictalker/comiccacher.py +++ b/comictalker/comiccacher.py @@ -183,7 +183,7 @@ class ComicCacher: count_of_issues=record[7], start_year=record[8], image_url=record[9], - aliases=record[10].split("\n") if record[10] else [], + aliases=record[10].strip().splitlines(), description=record[11], ) @@ -280,7 +280,7 @@ class ComicCacher: count_of_issues=row[3], start_year=row[4], image_url=row[5], - aliases=row[6].split("\n") if row[6] else [], + aliases=row[6].strip().splitlines(), description=row[7], ) @@ -322,13 +322,13 @@ class ComicCacher: image_url=row[6], description=row[8], volume=volume, - aliases=row[9].split("\n") if row[9] else [], - alt_image_urls=row[10].split("\n") if row[10] else [], - characters=row[11].split("\n") if row[11] else [], - locations=row[12].split("\n") if row[12] else [], + aliases=row[9].strip().splitlines(), + alt_image_urls=row[10].strip().splitlines(), + characters=row[11].strip().splitlines(), + locations=row[12].strip().splitlines(), credits=json.loads(row[13]), - teams=row[14].split("\n") if row[14] else [], - story_arcs=row[15].split("\n") if row[15] else [], + teams=row[14].strip().splitlines(), + story_arcs=row[15].strip().splitlines(), complete=bool(row[16]), ) @@ -374,13 +374,13 @@ class ComicCacher: image_thumb_url=row[7], description=row[8], volume=volume, - aliases=row[9].split("\n") if row[9] else [], - alt_image_urls=row[11].split("\n") if row[11] else [], - characters=row[12].split("\n") if row[12] else [], - locations=row[13].split("\n") if row[13] else [], + aliases=row[9].strip().splitlines(), + alt_image_urls=row[11].strip().splitlines(), + characters=row[12].strip().splitlines(), + locations=row[13].strip().splitlines(), credits=json.loads(row[14]), - teams=row[15].split("\n") if row[15] else [], - story_arcs=row[16].split("\n") if row[16] else [], + teams=row[15].strip().splitlines(), + story_arcs=row[16].strip().splitlines(), complete=bool(row[17]), ) diff --git a/comictalker/talkers/comicvine.py b/comictalker/talkers/comicvine.py index cbee2e2..05ba0c6 100644 --- a/comictalker/talkers/comicvine.py +++ b/comictalker/talkers/comicvine.py @@ -366,15 +366,12 @@ class ComicVineTalker(ComicTalker): if record.get("publisher") is None: pub_name = "" else: - pub_name = record["publisher"]["name"] + pub_name = record["publisher"].get("name", "") if record.get("image") is None: image_url = "" else: - if record["image"].get("super_url") is None: - image_url = "" - else: - image_url = record["image"]["super_url"] + image_url = record["image"].get("super_url", "") if record.get("start_year") is None: start_year = 0 @@ -383,7 +380,7 @@ class ComicVineTalker(ComicTalker): formatted_results.append( ComicVolume( - aliases=record["aliases"].split("\n") if record["aliases"] else [], + aliases=record["aliases"].split("\n") if record["aliases"] else [], # CV returns a null because...? count_of_issues=record.get("count_of_issues", 0), description=record.get("description", ""), id=record["id"], @@ -411,11 +408,8 @@ class ComicVineTalker(ComicTalker): alt_images_list = [] for alt in record["associated_images"]: - # Convert to comma separated alt_images_list.append(alt["original_url"]) - alt_image_urls = alt_images_list - character_list = [] if record.get("character_credits"): for char in record["character_credits"]: @@ -453,7 +447,7 @@ class ComicVineTalker(ComicTalker): name=record["name"], site_detail_url=record.get("site_detail_url", ""), volume=cast(ComicVolume, record["volume"]), - alt_image_urls=alt_image_urls, + alt_image_urls=alt_images_list, characters=character_list, locations=location_list, teams=teams_list, @@ -472,7 +466,6 @@ class ComicVineTalker(ComicTalker): refresh_cache: bool = False, literal: bool = False, ) -> list[ComicVolume]: - # Sanitize the series name for comicvine searching, comicvine search ignore symbols search_series_name = utils.sanitize_title(series_name, literal) logger.info(f"{self.source_name_friendly} searching: {search_series_name}") @@ -550,7 +543,7 @@ class ComicVineTalker(ComicTalker): if callback is not None: callback(current_result_count, total_result_count) - # Format result to ComicSearchResult + # Format result to ComicIssue formatted_search_results = self.format_search_results(search_results) # Cache these search results, even if it's literal we cache the results @@ -570,8 +563,6 @@ class ComicVineTalker(ComicTalker): return comic_data def fetch_partial_volume_data(self, series_id: int) -> ComicVolume: - # This is still required over fetch_volume_data because this can use the cache whereas fetch_volume_data always - # requires an API call # before we search online, look in our cache, since we might already have this info cvc = ComicCacher() cached_volume_result = cvc.get_volume_info(series_id, self.source_name) @@ -772,6 +763,7 @@ class ComicVineTalker(ComicTalker): self.settings_options["use_series_start_as_volume"]["value"], ) + # TODO Why is this required? Was this to get around ii and empty URL? def repair_urls(self, issue_list: list[CVIssueDetailResults]) -> None: # make sure there are URLs for the image fields for issue in issue_list: