jellyfin-kodi/service.py

58 lines
1.7 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
#################################################################################################
import logging
import os
import sys
2015-03-13 21:24:59 +00:00
import xbmc
import xbmcaddon
2015-03-13 21:24:59 +00:00
#################################################################################################
_ADDON = xbmcaddon.Addon(id='plugin.video.emby')
_CWD = _ADDON.getAddonInfo('path').decode('utf-8')
_BASE_LIB = xbmc.translatePath(os.path.join(_CWD, 'resources', 'lib')).decode('utf-8')
sys.path.append(_BASE_LIB)
2015-03-13 21:24:59 +00:00
#################################################################################################
2016-09-09 03:13:25 +00:00
import loghandler
from service_entry import Service
from utils import settings
2018-05-13 03:56:53 +00:00
#from ga_client import GoogleAnalytics
#################################################################################################
loghandler.config()
log = logging.getLogger("EMBY.service")
DELAY = int(settings('startupDelay') or 0)
2015-04-06 17:17:32 +00:00
#################################################################################################
2016-09-09 03:13:25 +00:00
if __name__ == "__main__":
2016-09-09 03:13:25 +00:00
log.warn("Delaying emby startup by: %s sec...", DELAY)
service = Service()
2016-09-09 03:13:25 +00:00
try:
abort = False
if DELAY and xbmc.Monitor().waitForAbort(DELAY):
log.info("Abort event while waiting to start Emby for kodi")
abort = True
2016-09-09 03:13:25 +00:00
# Start the service
if abort == False:
service.service_entry_point()
except Exception as error:
2018-05-13 03:56:53 +00:00
"""
if not (hasattr(error, 'quiet') and error.quiet):
ga = GoogleAnalytics()
errStrings = ga.formatException()
ga.sendEventData("Exception", errStrings[0], errStrings[1])
2018-05-13 03:56:53 +00:00
"""
log.exception(error)
log.info("Forcing shutdown")
service.shutdown()