Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preferred metadata language #137

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions resources/settings.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<setting label="General" type="lsep" />
<setting id="dlpath" type="folder" label="Download Path" source="auto" option="writeable" />
<setting id="keep_files" type="bool" label="Keep files after playback/download stops" default="false" />
<setting id="pref_language" type="labelenum" label="Preferred Metadata Language" values="system|aa|ab|af|am|ar|as|ay|az|ba|be|bg|bh|bi|bn|bo|br|ca|co|cs|cy|da|de|dz|el|en|eo|es|et|eu|fa|fi|fj|fo|fr|fy|ga|gd|gl|gn|gu|ha|hi|hr|hu|hy|ia|ie|ik|in|is|it|iw|ja|ji|jw|ka|kk|kl|km|kn|ko|ks|ku|ky|la|ln|lo|lt|lv|mg|mi|mk|ml|mn|mo|mr|ms|mt|my|na|ne|nl|no|oc|om|or|pa|pl|ps|pt|qu|rm|rn|ro|ru|rw|sa|sd|sg|sh|si|sk|sl|sm|sn|so|sq|sr|ss|st|su|sv|sw|ta|te|tg|th|ti|tk|tl|tn|to|tr|ts|tt|tw|uk|ur|uz|vi|vo|wo|xh|yo|zh|zu" default="system" />

<setting label="Content" type="lsep"/>
<setting id="immunicity" type="bool" label="Auto-unblocking via Immunicity" default="false" />
Expand Down
12 changes: 8 additions & 4 deletions resources/site-packages/xbmctorrent/tmdb.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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():
Expand All @@ -25,15 +25,19 @@ 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)


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)

Expand Down
4 changes: 3 additions & 1 deletion resources/site-packages/xbmctorrent/tvdb.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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 = {}
Expand Down
10 changes: 10 additions & 0 deletions resources/site-packages/xbmctorrent/utils.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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