From e72347656bc2810acef6602e5f71a5809d1692c3 Mon Sep 17 00:00:00 2001 From: Mizaki Date: Tue, 23 May 2023 00:27:58 +0100 Subject: [PATCH] Add format (1-shot, limited series, etc.) --- comictalker/comiccacher.py | 7 +++++++ comictalker/resulttypes.py | 1 + comictalker/talker_utils.py | 6 +++++- comictalker/talkers/comicvine.py | 1 + testing/comicdata.py | 2 ++ testing/comicvine.py | 1 + 6 files changed, 17 insertions(+), 1 deletion(-) diff --git a/comictalker/comiccacher.py b/comictalker/comiccacher.py index 1d9cfd8..90e0931 100644 --- a/comictalker/comiccacher.py +++ b/comictalker/comiccacher.py @@ -95,6 +95,7 @@ class ComicCacher: + "aliases TEXT," # Newline separated + "description TEXT," + "genres TEXT," # Newline separated. For filtering etc. + + "format TEXT," + "timestamp DATE DEFAULT (datetime('now','localtime')), " + "source_name TEXT NOT NULL," + "PRIMARY KEY (id, source_name))" @@ -163,6 +164,7 @@ class ComicCacher: "image_url": record.image_url, "description": record.description, "genres": "\n".join(record.genres), + "format": record.format, "timestamp": datetime.datetime.now(), "aliases": "\n".join(record.aliases), } @@ -197,6 +199,7 @@ class ComicCacher: aliases=record[12].strip().splitlines(), description=record[13], genres=record[14].strip().splitlines(), + format=record[15], ) results.append(result) @@ -223,6 +226,7 @@ class ComicCacher: "image_url": series_record.image_url, "description": series_record.description, "genres": "\n".join(series_record.genres), + "format": series_record.format, "timestamp": timestamp, "aliases": "\n".join(series_record.aliases), } @@ -302,6 +306,7 @@ class ComicCacher: aliases=row[8].strip().splitlines(), description=row[9], genres=row[10].strip().splitlines(), + format=row[11], ) return result @@ -320,6 +325,7 @@ class ComicCacher: count_of_issues=None, count_of_volumes=None, volume=None, + format=None, ) con = lite.connect(self.db_file) with con: @@ -405,6 +411,7 @@ class ComicCacher: count_of_issues=None, count_of_volumes=None, volume=None, + format=None, ) # now process the results diff --git a/comictalker/resulttypes.py b/comictalker/resulttypes.py index c7fa18c..debaa2e 100644 --- a/comictalker/resulttypes.py +++ b/comictalker/resulttypes.py @@ -23,6 +23,7 @@ class ComicSeries: publisher: str start_year: int | None genres: list[str] + format: str | None def copy(self) -> ComicSeries: return copy.deepcopy(self) diff --git a/comictalker/talker_utils.py b/comictalker/talker_utils.py index 4767e1c..180397d 100644 --- a/comictalker/talker_utils.py +++ b/comictalker/talker_utils.py @@ -45,9 +45,13 @@ def map_comic_issue_to_metadata( metadata.series = utils.xlate(issue_results.series.name) metadata.issue = IssueString(issue_results.issue_number).as_string() - # Rely on comic talker to valid this number + # Rely on comic talker to validate this number metadata.issue_count = utils.xlate_int(issue_results.series.volume) + # TODO Generate list in utils (same as language and countries) and check against that in separate PR + if issue_results.series.format: + metadata.format = issue_results.series.format + metadata.volume = utils.xlate_int(issue_results.series.volume) metadata.volume_count = utils.xlate_int(issue_results.series.count_of_volumes) diff --git a/comictalker/talkers/comicvine.py b/comictalker/talkers/comicvine.py index 9476c0d..3225306 100644 --- a/comictalker/talkers/comicvine.py +++ b/comictalker/talkers/comicvine.py @@ -518,6 +518,7 @@ class ComicVineTalker(ComicTalker): publisher=pub_name, start_year=start_year, genres=[], + format=None, ) ) diff --git a/testing/comicdata.py b/testing/comicdata.py index 7698437..4baf139 100644 --- a/testing/comicdata.py +++ b/testing/comicdata.py @@ -17,6 +17,7 @@ search_results = [ start_year=0, aliases=[], genres=[], + format=None, ), comictalker.resulttypes.ComicSeries( count_of_issues=1, @@ -30,6 +31,7 @@ search_results = [ start_year=0, aliases=[], genres=[], + format=None, ), ] diff --git a/testing/comicvine.py b/testing/comicvine.py index 7cb9df5..a4efb53 100644 --- a/testing/comicvine.py +++ b/testing/comicvine.py @@ -179,6 +179,7 @@ comic_issue_result = ComicIssue( publisher=cv_volume_result["results"]["publisher"]["name"], start_year=int(cv_volume_result["results"]["start_year"]), genres=[], + format=None, ), characters=[], alt_image_urls=[],