2015-07-22 13:16:08 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2015-06-05 06:05:40 +00:00
|
|
|
|
2015-09-24 11:59:26 +00:00
|
|
|
#################################################################################################
|
|
|
|
|
2016-07-24 08:59:48 +00:00
|
|
|
import logging
|
2015-06-05 06:05:40 +00:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
2015-03-13 21:24:59 +00:00
|
|
|
import xbmc
|
2018-09-07 08:22:08 +00:00
|
|
|
import xbmcvfs
|
2015-12-24 19:51:47 +00:00
|
|
|
import xbmcaddon
|
2015-03-13 21:24:59 +00:00
|
|
|
|
2015-09-24 11:59:26 +00:00
|
|
|
#################################################################################################
|
|
|
|
|
2018-10-12 01:24:33 +00:00
|
|
|
__addon__ = xbmcaddon.Addon(id='plugin.video.emby')
|
|
|
|
__base__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('path'), 'resources', 'lib')).decode('utf-8')
|
|
|
|
__pcache__ = xbmc.translatePath(os.path.join(__addon__.getAddonInfo('profile'), 'emby')).decode('utf-8')
|
|
|
|
__cache__ = xbmc.translatePath('special://temp/emby').decode('utf-8')
|
2018-09-07 08:22:08 +00:00
|
|
|
|
2018-10-12 01:24:33 +00:00
|
|
|
if not xbmcvfs.exists(__pcache__ + '/'):
|
|
|
|
from resources.lib.helper.utils import copytree
|
2018-09-07 08:22:08 +00:00
|
|
|
|
2018-10-12 01:24:33 +00:00
|
|
|
copytree(os.path.join(__base__, 'objects').decode('utf-8'), os.path.join(__pcache__, 'objects').decode('utf-8'))
|
|
|
|
|
|
|
|
sys.path.insert(0, __cache__)
|
|
|
|
sys.path.insert(0, __pcache__)
|
2018-09-06 08:36:32 +00:00
|
|
|
sys.path.append(__base__)
|
2015-03-13 21:24:59 +00:00
|
|
|
|
2015-09-24 11:59:26 +00:00
|
|
|
#################################################################################################
|
|
|
|
|
2018-09-06 08:36:32 +00:00
|
|
|
from entrypoint import Service
|
|
|
|
from helper import settings
|
|
|
|
from emby import Emby
|
2016-07-24 08:59:48 +00:00
|
|
|
|
|
|
|
#################################################################################################
|
|
|
|
|
2018-09-06 08:36:32 +00:00
|
|
|
LOG = logging.getLogger("EMBY.service")
|
2016-10-07 04:15:23 +00:00
|
|
|
DELAY = int(settings('startupDelay') or 0)
|
2015-04-06 17:17:32 +00:00
|
|
|
|
2015-09-24 11:59:26 +00:00
|
|
|
#################################################################################################
|
|
|
|
|
2018-09-06 08:36:32 +00:00
|
|
|
|
2016-09-09 03:13:25 +00:00
|
|
|
if __name__ == "__main__":
|
2016-09-21 07:39:50 +00:00
|
|
|
|
2018-10-03 23:25:51 +00:00
|
|
|
LOG.warn("-->[ service ]")
|
2018-09-06 08:36:32 +00:00
|
|
|
LOG.warn("Delay startup by %s seconds.", DELAY)
|
|
|
|
|
2016-09-21 07:39:50 +00:00
|
|
|
try:
|
2018-10-03 23:25:51 +00:00
|
|
|
session = Service()
|
2017-01-14 23:46:38 +00:00
|
|
|
|
2018-10-03 23:25:51 +00:00
|
|
|
try:
|
|
|
|
if DELAY and xbmc.Monitor().waitForAbort(DELAY):
|
|
|
|
raise Exception("Aborted during startup delay")
|
2018-09-06 08:36:32 +00:00
|
|
|
|
2018-10-03 23:25:51 +00:00
|
|
|
session.service()
|
|
|
|
except Exception as error: # TODO, build exceptions
|
|
|
|
LOG.exception(error)
|
|
|
|
session.shutdown()
|
|
|
|
|
|
|
|
except Exception as error:
|
|
|
|
''' Issue initializing the service.
|
|
|
|
'''
|
2018-09-06 08:36:32 +00:00
|
|
|
LOG.exception(error)
|
|
|
|
|
2018-10-03 23:25:51 +00:00
|
|
|
LOG.warn("--<[ service ]")
|