jellyfin-kodi/service.py

47 lines
1.4 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
#################################################################################################
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:
if DELAY and xbmc.Monitor().waitForAbort(DELAY):
raise RuntimeError("Abort event while waiting to start Emby for kodi")
2016-09-09 03:13:25 +00:00
# Start the service
service.service_entry_point()
except Exception as error:
log.exception(error)
log.info("Forcing shutdown")
service.shutdown()