Skip to content

Commit

Permalink
a few latest fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Nov 21, 2016
1 parent bed490f commit 929da03
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/artutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=""):
Expand Down
7 changes: 2 additions & 5 deletions lib/helpers/omdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
4 changes: 3 additions & 1 deletion lib/helpers/tmdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"):
Expand Down
17 changes: 8 additions & 9 deletions lib/helpers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 929da03

Please sign in to comment.