From d4c290effb5917503ee17dd14ff877f764172dcc Mon Sep 17 00:00:00 2001 From: tomkat83 Date: Wed, 31 May 2017 14:13:45 +0200 Subject: [PATCH] Choose to replace user ratings with #media versions --- .../language/resource.language.en_gb/strings.po | 12 +++++++++++- resources/lib/PlexAPI.py | 13 ++++++++++--- resources/lib/initialsetup.py | 6 ++++++ resources/lib/state.py | 2 ++ resources/lib/userclient.py | 2 ++ resources/settings.xml | 1 + 6 files changed, 32 insertions(+), 4 deletions(-) diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index 73e05ece..6a5d051c 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -1943,4 +1943,14 @@ msgstr "" # Shown once on first installation to comply with the terms of use of themoviedb.org msgctxt "#39717" msgid "PKC uses free additional artwork from www.themoviedb.org. Many thanks!" -msgstr "" \ No newline at end of file +msgstr "" + +# Shown during very first PKC setup only +msgctxt "#39718" +msgid "Do you want to replace your custom user ratings with an indicator of how many versions of a media item you posses?" +msgstr "" + +# In PKC Settings under Sync +msgctxt "#39719" +msgid "Replace user ratings with number of media versions" +msgstr "" diff --git a/resources/lib/PlexAPI.py b/resources/lib/PlexAPI.py index 8c307811..03f360f6 100644 --- a/resources/lib/PlexAPI.py +++ b/resources/lib/PlexAPI.py @@ -1288,10 +1288,17 @@ class API(): except (KeyError, ValueError): lastPlayedDate = None - try: - userrating = int(float(item['userRating'])) - except (KeyError, ValueError): + if state.INDICATE_MEDIA_VERSIONS is True: userrating = 0 + for entry in self.item.findall('./Media'): + userrating += 1 + # Don't show a value of '1' + userrating = 0 if userrating == 1 else userrating + else: + try: + userrating = int(float(item['userRating'])) + except (KeyError, ValueError): + userrating = 0 try: rating = float(item['audienceRating']) diff --git a/resources/lib/initialsetup.py b/resources/lib/initialsetup.py index 0c1d83ad..f29afa72 100644 --- a/resources/lib/initialsetup.py +++ b/resources/lib/initialsetup.py @@ -488,10 +488,16 @@ class InitialSetup(): if dialog.yesno(heading=lang(29999), line1=lang(39061)): log.debug("User opted to use FanArtTV") settings('FanartTV', value="true") + # Do you want to replace your custom user ratings with an indicator of + # how many versions of a media item you posses? + if dialog.yesno(heading=lang(29999), line1=lang(39718)): + log.debug("User opted to replace user ratings with version number") + settings('indicate_media_versions', value="true") # If you use several Plex libraries of one kind, e.g. "Kids Movies" and # "Parents Movies", be sure to check https://goo.gl/JFtQV9 dialog.ok(heading=lang(29999), line1=lang(39076)) + # Need to tell about our image source for collections: themoviedb.org dialog.ok(heading=lang(29999), line1=lang(39717)) # Make sure that we only ask these questions upon first installation diff --git a/resources/lib/state.py b/resources/lib/state.py index 865f4556..b364f749 100644 --- a/resources/lib/state.py +++ b/resources/lib/state.py @@ -22,6 +22,8 @@ RESTRICTED_USER = False # Direct Paths (True) or Addon Paths (False)? Along with # window('useDirectPaths') DIRECT_PATHS = False +# Shall we replace custom user ratings with the number of versions available? +INDICATE_MEDIA_VERSIONS = False # Along with window('plex_authenticated') AUTHENTICATED = False diff --git a/resources/lib/userclient.py b/resources/lib/userclient.py index 587bf1c7..f9671263 100644 --- a/resources/lib/userclient.py +++ b/resources/lib/userclient.py @@ -165,6 +165,8 @@ class UserClient(threading.Thread): if settings('useDirectPaths') == "1" else 'false') state.DIRECT_PATHS = True if settings('useDirectPaths') == "1" \ else False + state.INDICATE_MEDIA_VERSIONS = True \ + if settings('indicate_media_versions') == "true" else False window('plex_force_transcode_pix', value='true' if settings('force_transcode_pix') == "1" else 'false') diff --git a/resources/settings.xml b/resources/settings.xml index 8ff636c0..52865be1 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -59,6 +59,7 @@ +