Move kodi webserver details to state.py
This commit is contained in:
parent
cdd38c6ef7
commit
39014fe7f4
3 changed files with 31 additions and 32 deletions
|
@ -7,13 +7,13 @@ from shutil import rmtree
|
|||
from urllib import quote_plus, unquote
|
||||
from threading import Thread
|
||||
import requests
|
||||
import json_rpc as js
|
||||
|
||||
from xbmc import sleep, translatePath
|
||||
from xbmcvfs import exists
|
||||
|
||||
from utils import window, settings, language as lang, kodiSQL, tryEncode, \
|
||||
thread_methods, dialog, exists_dir, tryDecode
|
||||
import state
|
||||
|
||||
# Disable annoying requests warnings
|
||||
import requests.packages.urllib3
|
||||
|
@ -27,26 +27,6 @@ LOG = getLogger("PLEX." + __name__)
|
|||
ARTWORK_QUEUE = Queue()
|
||||
|
||||
|
||||
def setKodiWebServerDetails():
|
||||
"""
|
||||
Get the Kodi webserver details - used to set the texture cache
|
||||
"""
|
||||
xbmc_port = None
|
||||
xbmc_username = None
|
||||
xbmc_password = None
|
||||
if js.get_setting('services.webserver') in (None, False):
|
||||
# Enable the webserver, it is disabled
|
||||
xbmc_port = 8080
|
||||
xbmc_username = "kodi"
|
||||
js.set_setting('services.webserverport', xbmc_port)
|
||||
js.set_setting('services.webserver', True)
|
||||
# Webserver already enabled
|
||||
xbmc_port = js.get_setting('services.webserverport')
|
||||
xbmc_username = js.get_setting('services.webserverusername')
|
||||
xbmc_password = js.get_setting('services.webserverpassword')
|
||||
return (xbmc_port, xbmc_username, xbmc_password)
|
||||
|
||||
|
||||
def double_urlencode(text):
|
||||
return quote_plus(quote_plus(text))
|
||||
|
||||
|
@ -59,8 +39,6 @@ def double_urldecode(text):
|
|||
'DB_SCAN',
|
||||
'STOP_SYNC'])
|
||||
class Image_Cache_Thread(Thread):
|
||||
xbmc_host = 'localhost'
|
||||
xbmc_port, xbmc_username, xbmc_password = setKodiWebServerDetails()
|
||||
sleep_between = 50
|
||||
# Potentially issues with limited number of threads
|
||||
# Hence let Kodi wait till download is successful
|
||||
|
@ -94,8 +72,11 @@ class Image_Cache_Thread(Thread):
|
|||
try:
|
||||
requests.head(
|
||||
url="http://%s:%s/image/image://%s"
|
||||
% (self.xbmc_host, self.xbmc_port, url),
|
||||
auth=(self.xbmc_username, self.xbmc_password),
|
||||
% (state.WEBSERVER_HOST,
|
||||
state.WEBSERVER_PORT,
|
||||
url),
|
||||
auth=(state.WEBSERVER_USERNAME,
|
||||
state.WEBSERVER_PASSWORD),
|
||||
timeout=self.timeout)
|
||||
except requests.Timeout:
|
||||
# We don't need the result, only trigger Kodi to start the
|
||||
|
|
|
@ -78,3 +78,9 @@ PLEX_TRANSIENT_TOKEN = None
|
|||
# Kodi player states
|
||||
PLAYER_STATES = {}
|
||||
PLAYED_INFO = {}
|
||||
|
||||
# Kodi webserver details
|
||||
WEBSERVER_PORT = 8080
|
||||
WEBSERVER_USERNAME = 'kodi'
|
||||
WEBSERVER_PASSWORD = ''
|
||||
WEBSERVER_HOST = 'localhost'
|
||||
|
|
26
service.py
26
service.py
|
@ -1,8 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
###############################################################################
|
||||
|
||||
import logging
|
||||
from logging import getLogger
|
||||
from os import path as os_path
|
||||
from sys import path as sys_path, argv
|
||||
|
||||
|
@ -45,18 +43,32 @@ from PlexCompanion import PlexCompanion
|
|||
from command_pipeline import Monitor_Window
|
||||
from playback_starter import Playback_Starter
|
||||
from artwork import Image_Cache_Thread
|
||||
from json_rpc import get_setting, set_setting
|
||||
import variables as v
|
||||
import state
|
||||
|
||||
###############################################################################
|
||||
|
||||
import loghandler
|
||||
|
||||
loghandler.config()
|
||||
log = logging.getLogger("PLEX.service")
|
||||
|
||||
log = getLogger("PLEX.service")
|
||||
###############################################################################
|
||||
|
||||
def set_webserver():
|
||||
"""
|
||||
Set the Kodi webserver details - used to set the texture cache
|
||||
"""
|
||||
if get_setting('services.webserver') in (None, False):
|
||||
# Enable the webserver, it is disabled
|
||||
set_setting('services.webserver', True)
|
||||
# Set standard port and username
|
||||
set_setting('services.webserverport', 8080)
|
||||
set_setting('services.webserverusername', 'kodi')
|
||||
# Webserver already enabled
|
||||
state.WEBSERVER_PORT = get_setting('services.webserverport')
|
||||
state.WEBSERVER_USERNAME = get_setting('services.webserverusername')
|
||||
state.WEBSERVER_PASSWORD = get_setting('services.webserverpassword')
|
||||
|
||||
|
||||
class Service():
|
||||
|
||||
|
@ -80,7 +92,7 @@ class Service():
|
|||
image_cache_thread_running = False
|
||||
|
||||
def __init__(self):
|
||||
|
||||
set_webserver()
|
||||
self.monitor = Monitor()
|
||||
|
||||
window('plex_kodiProfile',
|
||||
|
|
Loading…
Reference in a new issue