Moved setting addon mode to utils

It was the only useful function left in setup.py since we've removed the rest of them over time
This commit is contained in:
Abby Gourlay 2020-03-30 02:48:09 +01:00
parent 7ee28a0c71
commit 2cef5b727f
4 changed files with 20 additions and 62 deletions

View file

@ -17,10 +17,9 @@ import objects
import connect
import client
import library
import setup
import monitor
from views import Views, verify_kodi_defaults
from helper import translate, window, settings, event, dialog
from helper import translate, window, settings, event, dialog, set_addon_mode
from helper.utils import JsonDebugPrinter
from jellyfin import Jellyfin
@ -133,7 +132,7 @@ class Service(xbmc.Monitor):
try:
self.connect.register()
setup.Setup()
set_addon_mode()
except Exception as error:
LOG.exception(error)

View file

@ -18,6 +18,7 @@ from .utils import unzip
from .utils import create_id
from .utils import convert_to_local as Local
from .utils import has_attribute
from .utils import set_addon_mode
from .wrapper import progress
from .wrapper import catch

View file

@ -460,6 +460,23 @@ def has_attribute(obj, name):
except AttributeError:
return False
def set_addon_mode():
''' Setup playback mode. If native mode selected, check network credentials.
'''
value = dialog("yesno",
heading=translate('playback_mode'),
line1=translate(33035),
nolabel=translate('addon_mode'),
yeslabel=translate('native_mode'))
settings('useDirectPaths', value="1" if value else "0")
if value:
dialog("ok", heading="{jellyfin}", line1=translate(33145))
LOG.info("Add-on playback: %s", settings('useDirectPaths') == "0")
class JsonDebugPrinter(object):

View file

@ -1,59 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import division, absolute_import, print_function, unicode_literals
#################################################################################################
import logging
from helper import translate, settings, dialog, JSONRPC
#################################################################################################
LOG = logging.getLogger("JELLYFIN." + __name__)
#################################################################################################
class Setup(object):
def __init__(self):
self.setup()
LOG.info("---<[ setup ]")
def setup(self):
minimum = "3.0.24"
cached = settings('MinimumSetup')
if cached == minimum:
return
if not cached:
self._is_mode()
LOG.info("Add-on playback: %s", settings('useDirectPaths') == "0")
# Setup completed
settings('MinimumSetup', minimum)
def _is_mode(self):
''' Setup playback mode. If native mode selected, check network credentials.
'''
value = dialog("yesno",
heading=translate('playback_mode'),
line1=translate(33035),
nolabel=translate('addon_mode'),
yeslabel=translate('native_mode'))
settings('useDirectPaths', value="1" if value else "0")
if value:
dialog("ok", heading="{jellyfin}", line1=translate(33145))
def _is_music(self):
value = dialog("yesno", heading="{jellyfin}", line1=translate(33039))
settings('enableMusic.bool', value=value)