From 552a319298d86ccf436f54dce10884499ba569f4 Mon Sep 17 00:00:00 2001 From: MichaelFitzurka Date: Fri, 22 Apr 2022 09:39:32 -0400 Subject: [PATCH] Adding CommunityRating. fitxes #258 --- comicapi/comicinfoxml.py | 2 ++ comicapi/genericmetadata.py | 4 ++++ comictaggerlib/settingswindow.py | 1 + comictaggerlib/taggerwindow.py | 10 ++++++++ comictaggerlib/ui/TemplateHelp.ui | 1 + comictaggerlib/ui/taggerwindow.ui | 38 +++++++++++++++++++++++++++++++ 6 files changed, 56 insertions(+) diff --git a/comicapi/comicinfoxml.py b/comicapi/comicinfoxml.py index 0bbb893..6a012c0 100644 --- a/comicapi/comicinfoxml.py +++ b/comicapi/comicinfoxml.py @@ -155,6 +155,7 @@ class ComicInfoXml: assign("LanguageISO", md.language) assign("Format", md.format) assign("AgeRating", md.maturity_rating) + assign("CommunityRating", md.community_rating) assign("BlackAndWhite", "Yes" if md.black_and_white else None) assign("Manga", md.manga) assign("Characters", md.characters) @@ -225,6 +226,7 @@ class ComicInfoXml: md.story_arc = utils.xlate(get("StoryArc")) md.series_group = utils.xlate(get("SeriesGroup")) md.maturity_rating = utils.xlate(get("AgeRating")) + md.community_rating = utils.xlate(get("CommunityRating")) tmp = utils.xlate(get("BlackAndWhite")) if tmp is not None and tmp.lower() in ["yes", "true", "1"]: diff --git a/comicapi/genericmetadata.py b/comicapi/genericmetadata.py index 1053847..ad0b99b 100644 --- a/comicapi/genericmetadata.py +++ b/comicapi/genericmetadata.py @@ -106,6 +106,7 @@ class GenericMetadata: self.black_and_white = None self.page_count = None self.maturity_rating = None + self.community_rating = None self.story_arc = None self.series_group = None @@ -168,6 +169,7 @@ class GenericMetadata: assign("manga", new_md.manga) assign("black_and_white", new_md.black_and_white) assign("maturity_rating", new_md.maturity_rating) + assign("community_rating", new_md.community_rating) assign("story_arc", new_md.story_arc) assign("series_group", new_md.series_group) assign("scan_info", new_md.scan_info) @@ -306,6 +308,7 @@ class GenericMetadata: if self.black_and_white: add_attr_string("black_and_white") add_attr_string("maturity_rating") + add_attr_string("community_rating") add_attr_string("story_arc") add_attr_string("series_group") add_attr_string("scan_info") @@ -372,6 +375,7 @@ md_test.manga = "No" md_test.black_and_white = None md_test.page_count = 24 md_test.maturity_rating = "Everyone 10+" +md_test.community_rating = "3.0" md_test.story_arc = "Here and Now" md_test.series_group = "Futuristic Tales" md_test.scan_info = "(CC BY-NC-SA 3.0)" diff --git a/comictaggerlib/settingswindow.py b/comictaggerlib/settingswindow.py index dafd2b1..5f6cd18 100644 --- a/comictaggerlib/settingswindow.py +++ b/comictaggerlib/settingswindow.py @@ -105,6 +105,7 @@ Accepts the following variables: {black_and_white} (boolean) {page_count} (integer) {maturity_rating} (string) +{community_rating} (float) {story_arc} (string) {series_group} (string) {scan_info} (string) diff --git a/comictaggerlib/taggerwindow.py b/comictaggerlib/taggerwindow.py index e1e87fe..ba4880a 100644 --- a/comictaggerlib/taggerwindow.py +++ b/comictaggerlib/taggerwindow.py @@ -768,6 +768,11 @@ Please choose options below, and select OK. assign_text(self.teTeams, md.teams) assign_text(self.teLocations, md.locations) + try: + self.dsbCommunityRating.setValue(float(md.community_rating)) + except: + self.dsbCommunityRating.setValue(0.0) + if md.format is not None and md.format != "": i = self.cbFormat.findText(md.format) if i == -1: @@ -883,6 +888,10 @@ Please choose options below, and select OK. md.notes = self.teNotes.toPlainText() md.maturity_rating = self.cbMaturityRating.currentText() + md.community_rating = utils.xlate("{:.1f}".format(self.dsbCommunityRating.value())) + if md.community_rating == "0.0": + md.community_rating = None + md.story_arc = self.leStoryArc.text() md.scan_info = self.leScanInfo.text() md.series_group = self.leSeriesGroup.text() @@ -1181,6 +1190,7 @@ Please choose options below, and select OK. self.teLocations, self.cbMaturityRating, self.cbFormat, + self.dsbCommunityRating, ] if self.save_data_style == MetaDataStyle.CIX: diff --git a/comictaggerlib/ui/TemplateHelp.ui b/comictaggerlib/ui/TemplateHelp.ui index ca1e8f9..afe3939 100644 --- a/comictaggerlib/ui/TemplateHelp.ui +++ b/comictaggerlib/ui/TemplateHelp.ui @@ -91,6 +91,7 @@ tr:nth-child(even) { <tr><td>{black_and_white}</td><td>boolean</td></tr> <tr><td>{page_count}</td><td>integer</td></tr> <tr><td>{maturity_rating}</td><td>string</td></tr> + <tr><td>{community_rating}</td><td>float</td></tr> <tr><td>{story_arc}</td><td>string</td></tr> <tr><td>{series_group}</td><td>string</td></tr> <tr><td>{scan_info}</td><td>string</td></tr> diff --git a/comictaggerlib/ui/taggerwindow.ui b/comictaggerlib/ui/taggerwindow.ui index af4448a..0d67f8c 100644 --- a/comictaggerlib/ui/taggerwindow.ui +++ b/comictaggerlib/ui/taggerwindow.ui @@ -981,6 +981,44 @@ + + + + Community Rating + + + + + + + + 0 + 0 + + + + + 80 + 16777215 + + + + false + + + 1 + + + 0.000000000000000 + + + 5.000000000000000 + + + 0.100000000000000 + + +