From 58b4b88f84e8dfae7ae1f67b11469441f4cb0ac5 Mon Sep 17 00:00:00 2001 From: schumi2004 Date: Tue, 15 Apr 2014 14:35:58 +0200 Subject: [PATCH] second attempt --- resources/settings.xml | 1 + resources/site-packages/xbmctorrent/tmdb.py | 12 ++++++++---- resources/site-packages/xbmctorrent/tvdb.py | 4 +++- resources/site-packages/xbmctorrent/utils.py | 10 ++++++++++ 4 files changed, 22 insertions(+), 5 deletions(-) mode change 100644 => 100755 resources/settings.xml mode change 100644 => 100755 resources/site-packages/xbmctorrent/tmdb.py mode change 100644 => 100755 resources/site-packages/xbmctorrent/tvdb.py mode change 100644 => 100755 resources/site-packages/xbmctorrent/utils.py diff --git a/resources/settings.xml b/resources/settings.xml old mode 100644 new mode 100755 index 7398df5..0313fa3 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -4,6 +4,7 @@ + diff --git a/resources/site-packages/xbmctorrent/tmdb.py b/resources/site-packages/xbmctorrent/tmdb.py old mode 100644 new mode 100755 index 32baeb3..3a4e249 --- a/resources/site-packages/xbmctorrent/tmdb.py +++ b/resources/site-packages/xbmctorrent/tmdb.py @@ -1,12 +1,12 @@ from xbmctorrent import plugin -from xbmctorrent.utils import memoize +from xbmctorrent.utils import memoize, get_api_language API_KEY = "57983e31fb435df4df77afb854740ea9" BASE_URL = "http://api.themoviedb.org/3" HEADERS = { "Referer": BASE_URL, } - +LANG = get_api_language() @memoize def tmdb_config(): @@ -25,7 +25,12 @@ def get(imdb_id): try: import urllib2 from xbmctorrent.utils import url_get_json - movie.update(url_get_json("%s/movie/%s" % (BASE_URL, imdb_id), params={"api_key": API_KEY, "append_to_response": "credits"}, headers=HEADERS, with_immunicity=False) or {}) + movie.update(url_get_json("%s/movie/%s" % (BASE_URL, imdb_id), params={"api_key": API_KEY,"language": LANG, "append_to_response": "credits"}, headers=HEADERS, with_immunicity=False) or {}) + overview = movie.get('overview') + if overview == None: + movie.update(url_get_json("%s/movie/%s" % (BASE_URL, imdb_id), params={"api_key": API_KEY,"language": "en", "append_to_response": "credits"}, headers=HEADERS, with_immunicity=False) or {}) + else: + pass except urllib2.HTTPError: pass return dict(movie) @@ -33,7 +38,6 @@ def get(imdb_id): def search(query, **kwargs): from xbmctorrent.utils import url_get_json - kwargs["query"] = query return url_get_json("%s/search/movie" % BASE_URL, params=kwargs, headers=HEADERS, with_immunicity=False) diff --git a/resources/site-packages/xbmctorrent/tvdb.py b/resources/site-packages/xbmctorrent/tvdb.py old mode 100644 new mode 100755 index fe26a81..ee1d16c --- a/resources/site-packages/xbmctorrent/tvdb.py +++ b/resources/site-packages/xbmctorrent/tvdb.py @@ -1,10 +1,12 @@ +from xbmctorrent.utils import get_api_language + BASE_URL = "http://www.thetvdb.com" HEADERS = { "Referer": BASE_URL, } API_URL = "%s/api" % BASE_URL API_KEY = "1D62F2F90030C444" -LANG = "en" +LANG = get_api_language() def dom2dict(node): ret = {} diff --git a/resources/site-packages/xbmctorrent/utils.py b/resources/site-packages/xbmctorrent/utils.py old mode 100644 new mode 100755 index 32444b6..8942b62 --- a/resources/site-packages/xbmctorrent/utils.py +++ b/resources/site-packages/xbmctorrent/utils.py @@ -238,3 +238,13 @@ def get_xbmc_language(): "french": "fr", } return langs.get(xbmc.getLanguage().lower()) + +def get_api_language(): + import xbmc + import xbmcaddon + lang = xbmcaddon.Addon().getSetting('pref_language') + if lang == "system": + lang = xbmc.getLanguage(xbmc.ISO_639_1) + else: + lang = xbmcaddon.Addon().getSetting('pref_language') + return lang \ No newline at end of file