Skip to content

Commit

Permalink
Hotfix (#72)
Browse files Browse the repository at this point in the history
* Fix external subtitles

* Fix index error

* Fix credentials encoding

* Fix music var reference
  • Loading branch information
angelblue05 authored Oct 31, 2016
1 parent c6b747c commit ea4059b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -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"/>
Expand Down
13 changes: 9 additions & 4 deletions resources/lib/connect/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ def _ensure(self):
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', [])

Expand All @@ -54,7 +57,9 @@ def _set(self, data):
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()

Expand Down
2 changes: 1 addition & 1 deletion resources/lib/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down
2 changes: 1 addition & 1 deletion resources/lib/objects/music.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ def add_updateSong(self, item):
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")

Expand Down
5 changes: 2 additions & 3 deletions resources/lib/playbackutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def externalSubs(self, playurl):
externalsubs.append(path)
except Exception as e:
log.error(e)
continue
externalsubs.append(url)
else:
externalsubs.append(url)

Expand All @@ -298,12 +298,11 @@ def _download_external_subs(self, src, dst, filename):

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
Expand Down

0 comments on commit ea4059b

Please sign in to comment.