* 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

@ -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()