From 929da03cea905833727517be38a21f37c0c767c5 Mon Sep 17 00:00:00 2001 From: marcelveldt Date: Mon, 21 Nov 2016 22:37:34 +0100 Subject: [PATCH] a few latest fixes --- lib/artutils.py | 2 +- lib/helpers/omdb.py | 7 ++----- lib/helpers/tmdb.py | 4 +++- lib/helpers/utils.py | 17 ++++++++--------- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/lib/artutils.py b/lib/artutils.py index 2d591d3..816e659 100644 --- a/lib/artutils.py +++ b/lib/artutils.py @@ -198,7 +198,7 @@ def get_animated_artwork(self, imdb_id, manual_select=False, ignore_cache=False) if refresh_needed: artwork = self.animatedart.get_animated_artwork( imdb_id, manual_select, ignore_cache=True) - return artwork + return {"art": artwork} @use_cache(14, True) def get_omdb_info(self, imdb_id="", title="", year="", content_type=""): diff --git a/lib/helpers/omdb.py b/lib/helpers/omdb.py index 5597dc4..de5ff68 100644 --- a/lib/helpers/omdb.py +++ b/lib/helpers/omdb.py @@ -96,6 +96,7 @@ def map_details(data): result["art"]["thumb"] = value elif key == "Metascore": result["metacritic.rating"] = value + result["rating.mc"] = value elif key == "imdbRating": result["rating.imdb"] = value result["rating"] = float(value) @@ -140,15 +141,11 @@ def map_details(data): result["rottentomatoesconsensus"] = value # legacy elif key == "tomatoUserMeter": result["rottentomatoes.usermeter"] = value - result["rottentomatoesaudiencemeter"] = value # legacy elif key == "tomatoUserRating": result["rottentomatoes.userrating"] = value result["rottentomatoes.userrating.percent"] = "%s" % (try_parse_int(float(value) * 10)) - result["rottentomatoesaudiencerating"] = value # legacy - result["rottentomatoesaudiencerating.percent"] = "%s" % (try_parse_int(float(value) * 10)) # legacy elif key == "tomatoUserReviews": - result["userreviews"] = int_with_commas(value) - result["rottentomatoesaudiencereviews"] = int_with_commas(value) # legacy + result["rottentomatoes.userreviews"] = int_with_commas(value) elif key == "tomatoURL": result["rottentomatoes.url"] = value return result diff --git a/lib/helpers/tmdb.py b/lib/helpers/tmdb.py index 0b5f70c..49e679e 100644 --- a/lib/helpers/tmdb.py +++ b/lib/helpers/tmdb.py @@ -7,7 +7,7 @@ Get metadata from The Movie Database ''' -from utils import get_json, KODI_LANGUAGE, try_parse_int, DialogSelect, get_compare_string +from utils import get_json, KODI_LANGUAGE, try_parse_int, DialogSelect, get_compare_string, int_with_commas from difflib import SequenceMatcher as SM from simplecache import use_cache from operator import itemgetter @@ -241,7 +241,9 @@ def map_details(self, data, media_type): details["runtime"] = data["runtime"] * 60 details["imdbnumber"] = data["imdb_id"] details["budget"] = data["budget"] + details["budget.formatted"] = int_with_commas(data["budget"]) details["revenue"] = data["revenue"] + details["revenue.formatted"] = int_with_commas(data["revenue"]) if data.get("production_companies"): details["studio"] = [item["name"] for item in data["production_companies"]] if data.get("production_countries"): diff --git a/lib/helpers/utils.py b/lib/helpers/utils.py index 1c2532f..fe06e0e 100644 --- a/lib/helpers/utils.py +++ b/lib/helpers/utils.py @@ -18,6 +18,12 @@ import simplejson as json except Exception: import json + +try: + from multiprocessing.pool import ThreadPool + SUPPORTS_POOL = True +except Exception: + SUPPORTS_POOL = False ADDON_ID = "script.module.skin.helper.artutils" KODI_LANGUAGE = xbmc.getLanguage(xbmc.ISO_639_1) @@ -112,14 +118,7 @@ def formatted_number(number): def process_method_on_list(method_to_run, items): '''helper method that processes a method on each listitem with pooling if the system supports it''' all_items = [] - - try: - from multiprocessing.pool import ThreadPool - supports_pool = True - except Exception: - supports_pool = False - - if supports_pool: + if SUPPORTS_POOL: pool = ThreadPool() try: all_items = pool.map(method_to_run, items) @@ -218,7 +217,7 @@ def extend_dict(org_dict, new_dict, allow_overwrite=None): org_dict[key].append(item) # previous value was str, combine both in list elif isinstance(org_dict[key], (str, unicode)): - org_dict[key] = [org_dict[key]] + org_dict[key] = org_dict[key].split(" / ") for item in value: if item not in org_dict[key]: org_dict[key].append(item)