mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 10:16:11 +00:00
Increase amount of logging
This commit is contained in:
parent
c321b266f0
commit
9ae99de8dd
30 changed files with 641 additions and 620 deletions
|
@ -138,6 +138,7 @@ class Database(object):
|
|||
try:
|
||||
loaded = self._get_database(databases[file]) if file in databases else file
|
||||
except Exception as error:
|
||||
LOG.exception(error)
|
||||
|
||||
for i in range(1, 10):
|
||||
alt_file = "%s-%s" % (file, i)
|
||||
|
@ -150,8 +151,8 @@ class Database(object):
|
|||
loaded = None
|
||||
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as error:
|
||||
LOG.exception(error)
|
||||
|
||||
if discovered and discovered != loaded:
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ LOG = logging.getLogger("JELLYFIN."+__name__)
|
|||
|
||||
class JellyfinDatabase():
|
||||
|
||||
|
||||
def __init__(self, cursor):
|
||||
self.cursor = cursor
|
||||
|
||||
|
@ -105,7 +104,6 @@ class JellyfinDatabase():
|
|||
def remove_wild_item(self, item_id):
|
||||
self.cursor.execute(QU.delete_item_by_wild, (item_id + "%",))
|
||||
|
||||
|
||||
def get_view_name(self, item_id):
|
||||
|
||||
try:
|
||||
|
@ -113,6 +111,7 @@ class JellyfinDatabase():
|
|||
|
||||
return self.cursor.fetchone()[0]
|
||||
except Exception as error:
|
||||
LOG.exception(error)
|
||||
return
|
||||
|
||||
def get_view(self, *args):
|
||||
|
@ -159,7 +158,6 @@ class JellyfinDatabase():
|
|||
self.cursor.execute(QU.get_version)
|
||||
version = self.cursor.fetchone()[0]
|
||||
except Exception as error:
|
||||
pass
|
||||
LOG.exception(error)
|
||||
|
||||
return version
|
||||
|
|
@ -73,7 +73,8 @@ def validate_view(library_id, item_id):
|
|||
'Recursive': True,
|
||||
'Ids': item_id
|
||||
})
|
||||
except Exception:
|
||||
except Exception as error:
|
||||
LOG.exception(error)
|
||||
return False
|
||||
|
||||
return True if len(result['Items']) else False
|
||||
|
@ -257,7 +258,7 @@ def _get_items(query, server_id=None):
|
|||
items['TotalRecordCount'] = _get(url, test_params, server_id=server_id)['TotalRecordCount']
|
||||
|
||||
except Exception as error:
|
||||
LOG.error("Failed to retrieve the server response %s: %s params:%s", url, error, params)
|
||||
LOG.exception("Failed to retrieve the server response %s: %s params:%s", url, error, params)
|
||||
|
||||
else:
|
||||
index = params.get('StartIndex', 0)
|
||||
|
@ -397,8 +398,6 @@ def get_objects(src, filename):
|
|||
|
||||
LOG.error(error)
|
||||
response = requests.get(src, stream=True, verify=False)
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
dl = xbmcvfs.File(path, 'w')
|
||||
dl.write(response.content)
|
||||
|
|
|
@ -137,7 +137,7 @@ class Service(xbmc.Monitor):
|
|||
self.connect.register()
|
||||
setup.Setup()
|
||||
except Exception as error:
|
||||
LOG.error(error)
|
||||
LOG.exception(error)
|
||||
|
||||
def stop_default(self):
|
||||
|
||||
|
@ -361,7 +361,7 @@ class Service(xbmc.Monitor):
|
|||
try:
|
||||
self.connect.register()
|
||||
except Exception as error:
|
||||
LOG.error(error)
|
||||
LOG.exception(error)
|
||||
|
||||
elif method == 'GUI.OnScreensaverDeactivated':
|
||||
|
||||
|
|
|
@ -248,8 +248,9 @@ class FullSync(object):
|
|||
raise
|
||||
|
||||
except Exception as error:
|
||||
LOG.exception(error)
|
||||
|
||||
if not 'Failed to validate path' in error:
|
||||
if 'Failed to validate path' not in error:
|
||||
|
||||
dialog("ok", heading="{jellyfin}", line1=_(33119))
|
||||
LOG.error("full sync exited unexpectedly")
|
||||
|
|
|
@ -484,7 +484,7 @@ class PlayUtils(object):
|
|||
try:
|
||||
subs.append(self.download_external_subs(url, filename))
|
||||
except Exception as error:
|
||||
LOG.error(error)
|
||||
LOG.exception(error)
|
||||
subs.append(url)
|
||||
else:
|
||||
subs.append(url)
|
||||
|
@ -512,7 +512,8 @@ class PlayUtils(object):
|
|||
try:
|
||||
response = requests.get(src, stream=True, verify=False)
|
||||
response.raise_for_status()
|
||||
except Exception as e:
|
||||
except Exception as error:
|
||||
LOG.exception(error)
|
||||
raise
|
||||
else:
|
||||
response.encoding = 'utf-8'
|
||||
|
|
|
@ -266,7 +266,8 @@ def indent(elem, level=0):
|
|||
else:
|
||||
if level and (not elem.tail or not elem.tail.strip()):
|
||||
elem.tail = i
|
||||
except Exception:
|
||||
except Exception as error:
|
||||
LOG.exception(error)
|
||||
return
|
||||
|
||||
def write_xml(content, file):
|
||||
|
@ -447,6 +448,6 @@ def convert_to_local(date):
|
|||
|
||||
return date.strftime('%Y-%m-%dT%H:%M:%S')
|
||||
except Exception as error:
|
||||
LOG.error(error)
|
||||
LOG.exception(error)
|
||||
|
||||
return str(date)
|
||||
|
|
|
@ -84,10 +84,11 @@ def stop(default=None):
|
|||
def wrapper(*args, **kwargs):
|
||||
|
||||
try:
|
||||
if should_stop():
|
||||
if should_stop(): # ??? TODO: Fixme
|
||||
raise Exception
|
||||
|
||||
except Exception as error:
|
||||
LOG.exception(error)
|
||||
|
||||
if default is not None:
|
||||
return default
|
||||
|
@ -142,7 +143,8 @@ def library_check():
|
|||
|
||||
try:
|
||||
views = self.jellyfin_db.get_views_by_media('music')[0]
|
||||
except Exception:
|
||||
except Exception as error:
|
||||
LOG.exception(error)
|
||||
return
|
||||
|
||||
view = {'Id': views[0], 'Name': views[1]}
|
||||
|
|
|
@ -112,6 +112,7 @@ class Jellyfin(object):
|
|||
|
||||
@ensure_client()
|
||||
def __getitem__(self, key):
|
||||
LOG.debug("__getitem__(%r)", key)
|
||||
return self.client[self.server_id][key]
|
||||
|
||||
def construct(self):
|
||||
|
@ -123,4 +124,5 @@ class Jellyfin(object):
|
|||
else:
|
||||
LOG.info("---[ START JELLYFINCLIENT: %s ]---", self.server_id)
|
||||
|
||||
|
||||
config()
|
|
@ -83,6 +83,7 @@ class JellyfinClient(object):
|
|||
self.http.stop_session()
|
||||
|
||||
def __getitem__(self, key):
|
||||
LOG.debug("__getitem__(%r)", key)
|
||||
|
||||
if key.startswith('config'):
|
||||
return self.config[key.replace('config/', "", 1)] if "/" in key else self.config
|
||||
|
|
|
@ -334,6 +334,3 @@ class API(object):
|
|||
return self._delete("Videos/ActiveEncodings", params={
|
||||
'DeviceId': device_id
|
||||
})
|
||||
|
||||
def delete_item(self, item_id):
|
||||
return self.items("/%s" % item_id, "DELETE")
|
||||
|
|
|
@ -16,6 +16,7 @@ LOG = logging.getLogger('JELLYFIN.'+__name__)
|
|||
|
||||
#################################################################################################
|
||||
|
||||
|
||||
class Config(object):
|
||||
|
||||
def __init__(self):
|
||||
|
@ -25,6 +26,7 @@ class Config(object):
|
|||
self.http()
|
||||
|
||||
def __shortcuts__(self, key):
|
||||
LOG.debug("__shortcuts__(%r)", key)
|
||||
|
||||
if key == "auth":
|
||||
return self.auth
|
||||
|
@ -38,14 +40,16 @@ class Config(object):
|
|||
return
|
||||
|
||||
def __getitem__(self, key):
|
||||
LOG.debug("__getitem__(%r)", key)
|
||||
return self.data.get(key, self.__shortcuts__(key))
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
self.data[key] = value
|
||||
|
||||
def app(self, name, version, device_name, device_id, capabilities=None, device_pixel_ratio=None):
|
||||
|
||||
LOG.info("Begin app constructor.")
|
||||
# import traceback
|
||||
# LOG.debug(''.join(['\n'] + traceback.format_stack()))
|
||||
|
||||
self.data['app.name'] = name
|
||||
self.data['app.version'] = version
|
||||
|
|
|
@ -60,6 +60,7 @@ class ConnectionManager(object):
|
|||
self.http = HTTP(client)
|
||||
|
||||
def __shortcuts__(self, key):
|
||||
LOG.debug("__shortcuts__(%r)", key)
|
||||
|
||||
if key == "clear":
|
||||
return self.clear_data
|
||||
|
@ -97,6 +98,7 @@ class ConnectionManager(object):
|
|||
return
|
||||
|
||||
def __getitem__(self, key):
|
||||
LOG.debug("__getitem__(%r)", key)
|
||||
return self.__shortcuts__(key)
|
||||
|
||||
def clear_data(self):
|
||||
|
@ -163,8 +165,8 @@ class ConnectionManager(object):
|
|||
}
|
||||
|
||||
result = self._request_url(request, False)
|
||||
except Exception as error: # Failed to login
|
||||
LOG.error(error)
|
||||
except Exception as error: # Failed to login
|
||||
LOG.exception(error)
|
||||
return False
|
||||
else:
|
||||
self._on_authenticated(result, options)
|
||||
|
@ -184,7 +186,8 @@ class ConnectionManager(object):
|
|||
|
||||
try:
|
||||
public_info = self._try_connect(address, options=options)
|
||||
except Exception:
|
||||
except Exception as error:
|
||||
LOG.exception(error)
|
||||
return _on_fail()
|
||||
else:
|
||||
LOG.info("connectToAddress %s succeeded", address)
|
||||
|
@ -258,7 +261,7 @@ class ConnectionManager(object):
|
|||
try:
|
||||
return self.http.request(request)
|
||||
except Exception as error:
|
||||
LOG.error(error)
|
||||
LOG.exception(error)
|
||||
raise
|
||||
|
||||
def _add_app_info(self):
|
||||
|
@ -352,7 +355,7 @@ class ConnectionManager(object):
|
|||
result = self._try_connect(address, timeout, options)
|
||||
|
||||
except Exception:
|
||||
LOG.error("test failed for connection mode %s with server %s", mode, server.get('Name'))
|
||||
LOG.exception("test failed for connection mode %s with server %s", mode, server.get('Name'))
|
||||
|
||||
if enable_retry:
|
||||
# TODO: wake on lan and retry
|
||||
|
@ -428,7 +431,7 @@ class ConnectionManager(object):
|
|||
try:
|
||||
sock.sendto(MESSAGE, MULTI_GROUP)
|
||||
except Exception as error:
|
||||
LOG.error(error)
|
||||
LOG.exception(error)
|
||||
return servers
|
||||
|
||||
while True:
|
||||
|
@ -441,7 +444,7 @@ class ConnectionManager(object):
|
|||
return servers
|
||||
|
||||
except Exception as e:
|
||||
LOG.error("Error trying to find servers: %s", e)
|
||||
LOG.exception("Error trying to find servers: %s", e)
|
||||
return servers
|
||||
|
||||
def _get_last_used_server(self):
|
||||
|
@ -579,6 +582,7 @@ class ConnectionManager(object):
|
|||
})
|
||||
self._update_server_info(server, system_info)
|
||||
except Exception as error:
|
||||
LOG.exception(error)
|
||||
|
||||
server['UserId'] = None
|
||||
server['AccessToken'] = None
|
||||
|
|
|
@ -39,7 +39,7 @@ class Credentials(object):
|
|||
if not isinstance(self.credentials, dict):
|
||||
raise ValueError("invalid credentials format")
|
||||
|
||||
except Exception as e: # File is either empty or missing
|
||||
except Exception as e: # File is either empty or missing
|
||||
LOG.warn(e)
|
||||
self.credentials = {}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ LOG = logging.getLogger('Jellyfin.'+__name__)
|
|||
|
||||
#################################################################################################
|
||||
|
||||
|
||||
class HTTP(object):
|
||||
|
||||
session = None
|
||||
|
@ -26,6 +27,7 @@ class HTTP(object):
|
|||
self.config = client['config']
|
||||
|
||||
def __shortcuts__(self, key):
|
||||
LOG.debug("__shortcuts__(%r)", key)
|
||||
|
||||
if key == "request":
|
||||
return self.request
|
||||
|
@ -90,7 +92,7 @@ class HTTP(object):
|
|||
|
||||
try:
|
||||
r = self._requests(session or self.session or requests, data.pop('type', "GET"), **data)
|
||||
r.content # release the connection
|
||||
r.content # release the connection
|
||||
|
||||
if not self.keep_alive and self.session is not None:
|
||||
self.stop_session()
|
||||
|
@ -137,7 +139,7 @@ class HTTP(object):
|
|||
|
||||
raise HTTPException("Unauthorized", error)
|
||||
|
||||
elif r.status_code == 500: # log and ignore.
|
||||
elif r.status_code == 500: # log and ignore.
|
||||
LOG.error("--[ 500 response ] %s", error)
|
||||
|
||||
return
|
||||
|
@ -214,7 +216,7 @@ class HTTP(object):
|
|||
|
||||
def _authorization(self, data):
|
||||
|
||||
auth = "MediaBrowser "
|
||||
auth = "MediaBrowser "
|
||||
auth += "Client=%s, " % self.config['app.name'].encode('utf-8')
|
||||
auth += "Device=%s, " % self.config['app.device_name'].encode('utf-8')
|
||||
auth += "DeviceId=%s, " % self.config['app.device_id'].encode('utf-8')
|
||||
|
|
|
@ -31,6 +31,7 @@ class WSClient(threading.Thread):
|
|||
threading.Thread.__init__(self)
|
||||
|
||||
def __shortcuts__(self, key):
|
||||
LOG.debug("__shortcuts__(%r)", key)
|
||||
|
||||
if key == "send":
|
||||
return self.send
|
||||
|
|
|
@ -746,6 +746,7 @@ class WebSocket(object):
|
|||
except socket.timeout as e:
|
||||
raise WebSocketTimeoutException(e.args[0])
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
if "timed out" in e.args[0]:
|
||||
raise WebSocketTimeoutException(e.args[0])
|
||||
else:
|
||||
|
@ -893,12 +894,13 @@ class WebSocketApp(object):
|
|||
break
|
||||
self._callback(self.on_message, data)
|
||||
|
||||
except Exception, e:
|
||||
#print str(e.args[0])
|
||||
except Exception as e:
|
||||
if "timed out" not in e.args[0]:
|
||||
logger.exception(e)
|
||||
raise e
|
||||
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
self._callback(self.on_error, e)
|
||||
finally:
|
||||
if thread:
|
||||
|
@ -911,11 +913,8 @@ class WebSocketApp(object):
|
|||
if callback:
|
||||
try:
|
||||
callback(self, *args)
|
||||
except Exception, e:
|
||||
logger.error(e)
|
||||
if True:#logger.isEnabledFor(logging.DEBUG):
|
||||
_, _, tb = sys.exc_info()
|
||||
traceback.print_tb(tb)
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -334,7 +334,7 @@ class Library(threading.Thread):
|
|||
|
||||
Views().get_nodes()
|
||||
except Exception as error:
|
||||
LOG.error(error)
|
||||
LOG.exception(error)
|
||||
|
||||
elif not settings('SyncInstallRunDone.bool'):
|
||||
|
||||
|
@ -459,7 +459,7 @@ class Library(threading.Thread):
|
|||
time_now = datetime.strptime(self.server['config/server-time'].split(', ', 1)[1], '%d %b %Y %H:%M:%S GMT') - timedelta(minutes=2)
|
||||
except Exception as error:
|
||||
|
||||
LOG.error(error)
|
||||
LOG.exception(error)
|
||||
time_now = datetime.utcnow() - timedelta(minutes=2)
|
||||
|
||||
last_sync = time_now.strftime('%Y-%m-%dT%H:%M:%Sz')
|
||||
|
@ -703,7 +703,9 @@ class SortWorker(threading.Thread):
|
|||
try:
|
||||
media = database.get_media_by_id(item_id)
|
||||
self.output[media].put({'Id': item_id, 'Type': media})
|
||||
except Exception:
|
||||
except Exception as error:
|
||||
LOG.exception(error)
|
||||
|
||||
items = database.get_media_by_parent_id(item_id)
|
||||
|
||||
if not items:
|
||||
|
|
|
@ -113,13 +113,14 @@ class Monitor(xbmc.Monitor):
|
|||
self.server_instance(data['ServerId'])
|
||||
except Exception as error:
|
||||
|
||||
LOG.error(error)
|
||||
LOG.exception(error)
|
||||
dialog("ok", heading="{jellyfin}", line1=_(33142))
|
||||
|
||||
return
|
||||
|
||||
server = Jellyfin(data['ServerId'])
|
||||
except Exception:
|
||||
except Exception as error:
|
||||
LOG.exception(error)
|
||||
server = Jellyfin()
|
||||
|
||||
if method == 'GetItem':
|
||||
|
@ -328,7 +329,7 @@ class Monitor(xbmc.Monitor):
|
|||
try:
|
||||
session = server['api'].get_device(self.device_id)
|
||||
except Exception as error:
|
||||
LOG.error(error)
|
||||
LOG.exception(error)
|
||||
|
||||
return
|
||||
|
||||
|
|
|
@ -765,7 +765,7 @@ def on_play(data, server):
|
|||
try:
|
||||
file = player.getPlayingFile()
|
||||
except Exception as error:
|
||||
LOG.error(error)
|
||||
LOG.exception(error)
|
||||
|
||||
return
|
||||
|
||||
|
|
|
@ -211,8 +211,8 @@ class GetArtworkWorker(threading.Thread):
|
|||
prep.url = "http://%s:%s/image/image://%s" % (self.kodi['host'], self.kodi['port'], url)
|
||||
s.send(prep, timeout=(0.01, 0.01))
|
||||
s.content # release the connection
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as error:
|
||||
LOG.exception(error)
|
||||
|
||||
self.queue.task_done()
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ class Movies(KodiDb):
|
|||
KodiDb.__init__(self, videodb.cursor)
|
||||
|
||||
def __getitem__(self, key):
|
||||
LOG.debug("__getitem__(%r)", key)
|
||||
|
||||
if key == 'Movie':
|
||||
return self.movie
|
||||
|
@ -175,7 +176,7 @@ class Movies(KodiDb):
|
|||
obj['Trailer'] = "plugin://plugin.video.youtube/play/?video_id=%s" % obj['Trailer'].rsplit('=', 1)[1]
|
||||
except Exception as error:
|
||||
|
||||
LOG.error("Failed to get trailer: %s", error)
|
||||
LOG.exception("Failed to get trailer: %s", error)
|
||||
obj['Trailer'] = None
|
||||
|
||||
def get_path_filename(self, obj):
|
||||
|
|
|
@ -35,6 +35,7 @@ class Music(KodiDb):
|
|||
KodiDb.__init__(self, musicdb.cursor)
|
||||
|
||||
def __getitem__(self, key):
|
||||
LOG.debug("__getitem__(%r)", key)
|
||||
|
||||
if key in ('MusicArtist', 'AlbumArtist'):
|
||||
return self.artist
|
||||
|
@ -219,7 +220,7 @@ class Music(KodiDb):
|
|||
self.artist(self.server['api'].get_item(temp_obj['Id']), library=None)
|
||||
temp_obj['ArtistId'] = self.jellyfin_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0]
|
||||
except Exception as error:
|
||||
LOG.error(error)
|
||||
LOG.exception(error)
|
||||
continue
|
||||
|
||||
self.update_artist_name(*values(temp_obj, QU.update_artist_name_obj))
|
||||
|
@ -375,7 +376,7 @@ class Music(KodiDb):
|
|||
self.artist(self.server['api'].get_item(temp_obj['Id']), library=None)
|
||||
temp_obj['ArtistId'] = self.jellyfin_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0]
|
||||
except Exception as error:
|
||||
LOG.error(error)
|
||||
LOG.exception(error)
|
||||
continue
|
||||
|
||||
self.link(*values(temp_obj, QU.update_link_obj))
|
||||
|
@ -409,7 +410,7 @@ class Music(KodiDb):
|
|||
self.artist(self.server['api'].get_item(temp_obj['Id']), library=None)
|
||||
temp_obj['ArtistId'] = self.jellyfin_db.get_item_by_id(*values(temp_obj, QUEM.get_item_obj))[0]
|
||||
except Exception as error:
|
||||
LOG.error(error)
|
||||
LOG.exception(error)
|
||||
continue
|
||||
|
||||
self.link_song_artist(*values(temp_obj, QU.update_song_artist_obj))
|
||||
|
|
|
@ -35,6 +35,7 @@ class MusicVideos(KodiDb):
|
|||
KodiDb.__init__(self, videodb.cursor)
|
||||
|
||||
def __getitem__(self, key):
|
||||
LOG.debug("__getitem__(%r)", key)
|
||||
|
||||
if key == 'MusicVideo':
|
||||
return self.musicvideo
|
||||
|
|
|
@ -38,6 +38,7 @@ class TVShows(KodiDb):
|
|||
KodiDb.__init__(self, videodb.cursor)
|
||||
|
||||
def __getitem__(self, key):
|
||||
LOG.debug("__getitem__(%r)", key)
|
||||
|
||||
if key == 'Series':
|
||||
return self.tvshow
|
||||
|
|
|
@ -12,6 +12,7 @@ LOG = logging.getLogger("JELLYFIN."+__name__)
|
|||
|
||||
#################################################################################################
|
||||
|
||||
|
||||
def get_play_action():
|
||||
|
||||
''' I could not figure out a way to listen to kodi setting changes?
|
||||
|
@ -22,16 +23,14 @@ def get_play_action():
|
|||
try:
|
||||
return options[result['result']['value']]
|
||||
except Exception as error:
|
||||
log.error("Returning play action due to error: %s", error)
|
||||
LOG.exception("Returning play action due to error: %s", error)
|
||||
|
||||
return options[1]
|
||||
|
||||
|
||||
def get_grouped_set():
|
||||
|
||||
''' Get if boxsets should be grouped
|
||||
'''
|
||||
result = JSONRPC('Settings.GetSettingValue').execute({'setting': "videolibrary.groupmoviesets"})
|
||||
try:
|
||||
return result['result']['value']
|
||||
except Exception as error:
|
||||
return False
|
||||
return result.get('result', {}).get('value', False)
|
||||
|
|
|
@ -135,7 +135,7 @@ class Player(xbmc.Player):
|
|||
|
||||
try:
|
||||
seektime = self.getTime()
|
||||
except Exception: # at this point we should be playing and if not then bail out
|
||||
except Exception: # at this point we should be playing and if not then bail out
|
||||
return
|
||||
|
||||
result = JSONRPC('Application.GetProperties').execute({'properties': ["volume", "muted"]})
|
||||
|
@ -193,22 +193,22 @@ class Player(xbmc.Player):
|
|||
|
||||
params = {
|
||||
'playerid': 1,
|
||||
'properties': ["currentsubtitle","currentaudiostream","subtitleenabled"]
|
||||
'properties': ["currentsubtitle", "currentaudiostream", "subtitleenabled"]
|
||||
}
|
||||
result = JSONRPC('Player.GetProperties').execute(params)
|
||||
result = result.get('result')
|
||||
|
||||
try: # Audio tracks
|
||||
try: # Audio tracks
|
||||
audio = result['currentaudiostream']['index']
|
||||
except (KeyError, TypeError):
|
||||
audio = 0
|
||||
|
||||
try: # Subtitles tracks
|
||||
try: # Subtitles tracks
|
||||
subs = result['currentsubtitle']['index']
|
||||
except (KeyError, TypeError):
|
||||
subs = 0
|
||||
|
||||
try: # If subtitles are enabled
|
||||
try: # If subtitles are enabled
|
||||
subs_enabled = result['subtitleenabled']
|
||||
except (KeyError, TypeError):
|
||||
subs_enabled = False
|
||||
|
|
|
@ -33,7 +33,7 @@ class WebService(threading.Thread):
|
|||
conn.request("QUIT", "/")
|
||||
conn.getresponse()
|
||||
except Exception as error:
|
||||
pass
|
||||
LOG.exception(error)
|
||||
|
||||
def run(self):
|
||||
|
||||
|
@ -46,7 +46,7 @@ class WebService(threading.Thread):
|
|||
server.serve_forever()
|
||||
except Exception as error:
|
||||
|
||||
if '10053' not in error: # ignore host diconnected errors
|
||||
if '10053' not in error: # ignore host diconnected errors
|
||||
LOG.exception(error)
|
||||
|
||||
LOG.info("---<[ webservice ]")
|
||||
|
@ -132,13 +132,13 @@ class requestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
|||
self.wfile.write(path)
|
||||
|
||||
except IndexError as error:
|
||||
LOG.exception(error)
|
||||
|
||||
xbmc.log(str(error), xbmc.LOGWARNING)
|
||||
self.send_error(404, "Exception occurred: %s" % error)
|
||||
|
||||
except Exception as error:
|
||||
LOG.exception(error)
|
||||
|
||||
xbmc.log(str(error), xbmc.LOGWARNING)
|
||||
self.send_error(500, "Exception occurred: %s" % error)
|
||||
|
||||
return
|
||||
|
|
|
@ -64,10 +64,11 @@ class ServiceManager(threading.Thread):
|
|||
|
||||
service.service()
|
||||
except Exception as error:
|
||||
LOG.exception(error)
|
||||
|
||||
if service is not None:
|
||||
|
||||
if not 'ExitService' in error:
|
||||
if 'ExitService' not in error:
|
||||
service.shutdown()
|
||||
|
||||
if 'RestartService' in error:
|
||||
|
@ -91,7 +92,7 @@ if __name__ == "__main__":
|
|||
try:
|
||||
session = ServiceManager()
|
||||
session.start()
|
||||
session.join() # Block until the thread exits.
|
||||
session.join() # Block until the thread exits.
|
||||
|
||||
if 'RestartService' in session.exception:
|
||||
continue
|
||||
|
|
1
tox.ini
1
tox.ini
|
@ -1,3 +1,4 @@
|
|||
[flake8]
|
||||
max-line-length = 9999
|
||||
import-order-style = pep8
|
||||
exclude = ./.git,./.vscode,./libraries
|
||||
|
|
Loading…
Reference in a new issue