* Fix external subtitles

* Fix index error

* Fix credentials encoding

* Fix music var reference
This commit is contained in:
angelblue05 2016-10-31 06:30:09 -05:00 committed by GitHub
parent c6b747cb04
commit ea4059b6d0
5 changed files with 14 additions and 10 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.emby"
name="Emby"
version="2.3.1"
version="2.3.2"
provider-name="Emby.media">
<requires>
<import addon="xbmc.python" version="2.19.0"/>

View file

@ -34,12 +34,15 @@ class Credentials(object):
if self.credentials is None:
try:
with open(os.path.join(self.path, 'data.txt')) as infile:
self.credentials = json.load(unicode(infile))
self.credentials = json.load(infile)
if not isinstance(self.credentials, dict):
raise ValueError("invalid credentials format")
except Exception as e: # File is either empty or missing
log.warn(e)
self.credentials = {}
log.info("credentials initialized with: %s" % self.credentials)
self.credentials['Servers'] = self.credentials.setdefault('Servers', [])
@ -54,7 +57,9 @@ class Credentials(object):
self.credentials = data
# Set credentials to file
with open(os.path.join(self.path, 'data.txt'), 'w') as outfile:
json.dump(unicode(data), outfile, indent=4, ensure_ascii=False)
for server in data['Servers']:
server['Name'] = server['Name'].encode('utf-8')
json.dump(data, outfile, ensure_ascii=False)
else:
self._clear()

View file

@ -372,7 +372,7 @@ def addUser():
result = doUtils.downloadUrl(url)
try:
additionalUsers = result[0]['AdditionalUsers']
except (KeyError, TypeError) as error:
except (IndexError, KeyError, TypeError) as error:
log.error(error)
additionaluser = []

View file

@ -490,7 +490,7 @@ class Music(Items):
except TypeError:
# No album found, create a single's album
log.info("Failed to add album. Creating singles.")
album_id = self.kodi_db.create_entry_album()
albumid = self.kodi_db.create_entry_album()
if self.kodi_version == 16:
self.kodi_db.add_single(albumid, genre, year, "single")

View file

@ -276,7 +276,7 @@ class PlaybackUtils():
externalsubs.append(path)
except Exception as e:
log.error(e)
continue
externalsubs.append(url)
else:
externalsubs.append(url)
@ -298,12 +298,11 @@ class PlaybackUtils():
try:
response = requests.get(src, stream=True)
response.encoding = 'utf-8'
response.raise_for_status()
except Exception as e:
del response
raise
else:
response.encoding = 'utf-8'
with open(path, 'wb') as f:
f.write(response.content)
del response