Fix subtitle languages showing up as unknown

- Fixes #342
This commit is contained in:
croneter 2017-09-28 14:13:00 +02:00
parent 6e5a14cf20
commit 345a24f896
2 changed files with 64 additions and 2 deletions

View file

@ -2369,11 +2369,15 @@ class API():
# ext = stream.attrib.get('format')
if key:
# We do know the language - temporarily download
if stream.attrib.get('language') is not None:
if stream.attrib.get('languageCode') is not None:
try:
language = v.LANGUAGECODE_TO_LANGUAGE[stream.attrib['languageCode']]
except KeyError:
language = stream.attrib['languageCode']
path = self.download_external_subtitles(
"{server}%s" % key,
"subtitle%02d.%s.%s" % (fileindex,
stream.attrib['language'],
language,
stream.attrib['codec']))
fileindex += 1
# We don't know the language - no need to download

View file

@ -21,8 +21,66 @@ def tryDecode(string, encoding='utf-8'):
string = string.decode()
return string
# When does Plex mark a video as completely played?
MARK_PLAYED_AT = 0.9
# Matching table for using Plex XML's stream 'languageCode'
LANGUAGECODE_TO_LANGUAGE = {
'afr': 'Afrikaans',
'ara': 'Arabic',
'hye': 'Armenian',
'bul': 'Bulgarian',
'cat': 'Catala',
'chi': 'Mandarin',
'hrv': 'Hrvatski',
'cze': 'Cesky',
'dan': 'Dansk',
'dut': 'Nederlands',
'eng': 'English',
'epo': 'Esperanto',
'fin': 'Suomi',
'fre': 'Francais',
'ger': 'Deutsch',
'geo': 'Georgian',
'gre': 'Greek',
'heb': 'Hebrew',
'hin': 'Hindi',
'hun': 'Magyar',
'ind': 'Bahasa Indonesia',
'gle': 'Gaeilge',
'ice': 'Islenska',
'ita': 'Italiano',
'jpn': 'Japanese',
'kor': 'Korean',
'kur': 'Kurdi',
'lat': 'Latin',
'mac': 'Macedonian',
'may': 'Malay',
'mlt': 'Malti',
'nep': 'Nepali',
'nor': 'Norsk',
'per': 'Persian',
'pol': 'Polszczyzna',
'por': 'Portugues',
'rum': 'Romana',
'rus': 'Russian',
'srp': 'Serbian',
'gla': 'Gaidhlig',
'slo': 'Slovencina',
'slv': 'Slovenski Jezik',
'spa': 'Espanol',
'swe': 'Svenska',
'tam': 'Tamil',
'tha': 'Thai',
'tur': 'Turkish',
'tah': 'Tahitian',
'ukr': 'Ukrainian',
'uzb': 'Ozbek',
'vie': 'Tieng Viet',
'wel': 'Cymraeg',
'yid': 'Yiddish',
}
_ADDON = Addon()
ADDON_NAME = 'PlexKodiConnect'
ADDON_ID = 'plugin.video.plexkodiconnect'