mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-11-10 04:06:11 +00:00
113 lines
3.6 KiB
Python
113 lines
3.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
#################################################################################################
|
|
|
|
import logging
|
|
|
|
import xbmc
|
|
|
|
from helper import _, settings, dialog, JSONRPC
|
|
|
|
#################################################################################################
|
|
|
|
LOG = logging.getLogger("EMBY."+__name__)
|
|
|
|
#################################################################################################
|
|
|
|
|
|
class Setup(object):
|
|
|
|
def __init__(self):
|
|
|
|
self.set_web_server()
|
|
self.setup()
|
|
|
|
LOG.info("---<[ setup ]")
|
|
|
|
def set_web_server(self):
|
|
|
|
''' Enable the webserver if not enabled. This is used to cache artwork.
|
|
Will only test once, if it fails, user will be notified only once.
|
|
'''
|
|
if settings('enableTextureCache.bool'):
|
|
|
|
get_setting = JSONRPC('Settings.GetSettingValue')
|
|
enabled = self.get_web_server()
|
|
|
|
if not enabled:
|
|
|
|
set_setting = JSONRPC('Settings.SetSetingValue')
|
|
set_setting.execute({'setting': "services.webserverport", 'value': 50325})
|
|
set_setting.execute({'setting': "services.webserver", 'value': True})
|
|
enabled = self.get_web_server()
|
|
|
|
if not enabled:
|
|
|
|
settings('enableTextureCache.bool', False)
|
|
dialog("ok", heading="{emby}", line1=_(33103))
|
|
|
|
return
|
|
|
|
result = get_setting.execute({'setting': "services.webserverport"})
|
|
settings('webServerPort', str(result['result']['value'] or ""))
|
|
result = get_setting.execute({'setting': "services.webserverusername"})
|
|
settings('webServerUser', str(result['result']['value'] or ""))
|
|
result = get_setting.execute({'setting': "services.webserverpassword"})
|
|
settings('webServerPass', str(result['result']['value'] or ""))
|
|
settings('useWebServer.bool', True)
|
|
|
|
def get_web_server(self):
|
|
|
|
result = JSONRPC('Settings.GetSettingValue').execute({'setting': "services.webserver"})
|
|
|
|
try:
|
|
return result['result']['value']
|
|
except (KeyError, TypeError):
|
|
return False
|
|
|
|
def setup(self):
|
|
|
|
minimum = "3.0.23"
|
|
|
|
if settings('MinimumSetup') == minimum:
|
|
return
|
|
|
|
self._is_mode()
|
|
LOG.info("Add-on playback: %s", settings('useDirectPaths') == "0")
|
|
self._is_artwork_caching()
|
|
LOG.info("Artwork caching: %s", settings('enableTextureCache.bool'))
|
|
self._is_empty_shows()
|
|
LOG.info("Sync empty shows: %s", settings('syncEmptyShows.bool'))
|
|
|
|
# Setup completed
|
|
settings('MinimumSetup', minimum)
|
|
|
|
def _is_mode(self):
|
|
|
|
''' Setup playback mode. If native mode selected, check network credentials.
|
|
'''
|
|
value = dialog("yesno",
|
|
heading=_('playback_mode'),
|
|
line1=_(33035),
|
|
nolabel=_('addon_mode'),
|
|
yeslabel=_('native_mode'))
|
|
|
|
settings('useDirectPaths', value="1" if value else "0")
|
|
|
|
if value:
|
|
dialog("ok", heading="{emby}", line1=_(33145))
|
|
|
|
def _is_artwork_caching(self):
|
|
|
|
value = dialog("yesno", heading="{emby}", line1=_(33117))
|
|
settings('enableTextureCache.bool', value)
|
|
|
|
def _is_empty_shows(self):
|
|
|
|
value = dialog("yesno", heading="{emby}", line1=_(33100))
|
|
settings('syncEmptyShows.bool', value)
|
|
|
|
def _is_music(self):
|
|
|
|
value = dialog("yesno", heading="{emby}", line1=_(33039))
|
|
settings('enableMusic.bool', value=value)
|