Merge pull request #452 from oddstr13/pr-json-encoding-1

Encoding parameter to json.load was removed in Python 3.9
This commit is contained in:
mcarlton00 2020-12-21 19:11:14 -05:00 committed by GitHub
commit 1982d32ab3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 13 deletions

View File

@ -3,10 +3,10 @@ from __future__ import division, absolute_import, print_function, unicode_litera
#################################################################################################
import datetime
import logging
import json
import os
import sqlite3
import sys
from kodi_six import xbmc, xbmcvfs
from six import text_type
@ -317,13 +317,15 @@ def reset_artwork():
def get_sync():
if (3, 0) <= sys.version_info < (3, 6):
LOG.error("Python versions 3.0-3.5 are NOT supported.")
if not xbmcvfs.exists(ADDON_DATA):
xbmcvfs.mkdirs(ADDON_DATA)
try:
with open(os.path.join(ADDON_DATA, 'sync.json'), 'rb') as infile:
sync = json.load(infile, encoding='utf-8')
sync = json.load(infile)
except Exception:
sync = {}
@ -350,22 +352,16 @@ def save_sync(sync):
def get_credentials():
if (3, 0) <= sys.version_info < (3, 6):
LOG.error("Python versions 3.0-3.5 are NOT supported.")
if not xbmcvfs.exists(ADDON_DATA):
xbmcvfs.mkdirs(ADDON_DATA)
try:
with open(os.path.join(ADDON_DATA, 'data.json'), 'rb') as infile:
credentials = json.load(infile, encoding='utf8')
except Exception:
try:
with open(os.path.join(ADDON_DATA, 'data.txt'), 'rb') as infile:
credentials = json.load(infile, encoding='utf-8')
save_credentials(credentials)
xbmcvfs.delete(os.path.join(ADDON_DATA, 'data.txt'))
except Exception:
credentials = json.load(infile)
except IOError:
credentials = {}
credentials['Servers'] = credentials.get('Servers', [])