Fix KeyError in library sync

This commit is contained in:
tomkat83 2016-03-10 12:47:30 +01:00
parent fa7bc1285e
commit 5be1e3a24a
3 changed files with 11 additions and 9 deletions

View file

@ -396,6 +396,7 @@
<string id="39307">Enter PIN for user </string> <string id="39307">Enter PIN for user </string>
<string id="39308">Could not log in user </string> <string id="39308">Could not log in user </string>
<string id="39309">Please try again.</string> <string id="39309">Please try again.</string>
<string id="39310">unknown</string>
<!-- Plex Librarysync.py --> <!-- Plex Librarysync.py -->
<string id="39400">Library sync thread has crashed. You should restart Kodi now. Please report this on the forum</string> <string id="39400">Library sync thread has crashed. You should restart Kodi now. Please report this on the forum</string>

View file

@ -328,6 +328,7 @@
<string id="39307">PIN eingeben für Benutzer </string> <string id="39307">PIN eingeben für Benutzer </string>
<string id="39308">Anmeldung fehlgeschlagen für Benutzer </string> <string id="39308">Anmeldung fehlgeschlagen für Benutzer </string>
<string id="39309">Bitte erneut versuchen.</string> <string id="39309">Bitte erneut versuchen.</string>
<string id="39310">unbekannt</string>
<!-- Plex Librarysync.py --> <!-- Plex Librarysync.py -->
<string id="39400">Die Synchronisierung der Plex Bibliotheken ist abgestürzt. Bitte Kodi neu starten. Danke, wenn Sie sich die Zeit nehmen und im Plex Forum vom Absturz berichten.</string> <string id="39400">Die Synchronisierung der Plex Bibliotheken ist abgestürzt. Bitte Kodi neu starten. Danke, wenn Sie sich die Zeit nehmen und im Plex Forum vom Absturz berichten.</string>

View file

@ -1428,6 +1428,8 @@ class API():
self.part = 0 self.part = 0
self.clientinfo = clientinfo.ClientInfo() self.clientinfo = clientinfo.ClientInfo()
self.clientId = self.clientinfo.getDeviceId() self.clientId = self.clientinfo.getDeviceId()
self.__language__ = xbmcaddon.Addon().getLocalizedString
self.userId = utils.window('emby_currUser') self.userId = utils.window('emby_currUser')
self.server = utils.window('emby_server%s' % self.userId) self.server = utils.window('emby_server%s' % self.userId)
self.token = utils.window('emby_accessToken%s' % self.userId) self.token = utils.window('emby_accessToken%s' % self.userId)
@ -2007,21 +2009,19 @@ class API():
elif mediaType == 2: # Audio streams elif mediaType == 2: # Audio streams
audiotrack = {} audiotrack = {}
audiotrack['codec'] = mediaStream['codec'].lower() audiotrack['codec'] = mediaStream['codec'].lower()
profile = mediaStream['codecID'].lower() profile = mediaStream.get('codecID', '').lower()
if "dca" in audiotrack['codec'] and "dts-hd ma" in profile: if "dca" in audiotrack['codec'] and "dts-hd ma" in profile:
audiotrack['codec'] = "dtshd_ma" audiotrack['codec'] = "dtshd_ma"
audiotrack['channels'] = mediaStream.get('channels') audiotrack['channels'] = mediaStream.get('channels')
try: # 'unknown' if we cannot get language
audiotrack['language'] = mediaStream.get('language') audiotrack['language'] = mediaStream.get(
except KeyError: 'language', self.__language__(39310))
audiotrack['language'] = 'unknown'
audiotracks.append(audiotrack) audiotracks.append(audiotrack)
elif mediaType == 3: # Subtitle streams elif mediaType == 3: # Subtitle streams
try: # 'unknown' if we cannot get language
subtitlelanguages.append(mediaStream['language']) subtitlelanguages.append(
except: mediaStream.get('language', self.__language__(39310)))
subtitlelanguages.append("Unknown")
return { return {
'video': videotracks, 'video': videotracks,
'audio': audiotracks, 'audio': audiotracks,