mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-24 09:46:11 +00:00
Removed webservice
This commit is contained in:
parent
8ab50c767e
commit
ebcbd1893f
3 changed files with 0 additions and 148 deletions
|
@ -427,6 +427,5 @@ class Service(xbmc.Monitor):
|
||||||
if self.monitor is not None:
|
if self.monitor is not None:
|
||||||
|
|
||||||
self.monitor.listener.stop()
|
self.monitor.listener.stop()
|
||||||
self.monitor.webservice.stop()
|
|
||||||
|
|
||||||
LOG.info("---<<<[ %s ]", client.get_addon_name())
|
LOG.info("---<<<[ %s ]", client.get_addon_name())
|
||||||
|
|
|
@ -17,7 +17,6 @@ from objects import PlaylistWorker, on_play, on_update, special_listener
|
||||||
from helper import translate, settings, window, dialog, api, JSONRPC
|
from helper import translate, settings, window, dialog, api, JSONRPC
|
||||||
from helper.utils import JsonDebugPrinter
|
from helper.utils import JsonDebugPrinter
|
||||||
from jellyfin import Jellyfin
|
from jellyfin import Jellyfin
|
||||||
from webservice import WebService
|
|
||||||
from helper import LazyLogger
|
from helper import LazyLogger
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
@ -38,8 +37,6 @@ class Monitor(xbmc.Monitor):
|
||||||
self.device_id = get_device_id()
|
self.device_id = get_device_id()
|
||||||
self.listener = Listener(self)
|
self.listener = Listener(self)
|
||||||
self.listener.start()
|
self.listener.start()
|
||||||
self.webservice = WebService()
|
|
||||||
self.webservice.start()
|
|
||||||
xbmc.Monitor.__init__(self)
|
xbmc.Monitor.__init__(self)
|
||||||
|
|
||||||
def onScanStarted(self, library):
|
def onScanStarted(self, library):
|
||||||
|
|
|
@ -1,144 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
from __future__ import division, absolute_import, print_function, unicode_literals
|
|
||||||
|
|
||||||
#################################################################################################
|
|
||||||
|
|
||||||
import threading
|
|
||||||
|
|
||||||
from six.moves import BaseHTTPServer
|
|
||||||
from six.moves import http_client as httplib
|
|
||||||
from six.moves.urllib.parse import parse_qsl
|
|
||||||
|
|
||||||
from kodi_six import xbmc
|
|
||||||
|
|
||||||
from helper import LazyLogger
|
|
||||||
|
|
||||||
#################################################################################################
|
|
||||||
|
|
||||||
LOG = LazyLogger(__name__)
|
|
||||||
PORT = 57578
|
|
||||||
|
|
||||||
#################################################################################################
|
|
||||||
|
|
||||||
|
|
||||||
class WebService(threading.Thread):
|
|
||||||
|
|
||||||
''' Run a webservice to trigger playback.
|
|
||||||
'''
|
|
||||||
def __init__(self):
|
|
||||||
threading.Thread.__init__(self)
|
|
||||||
|
|
||||||
def stop(self):
|
|
||||||
|
|
||||||
''' Called when the thread needs to stop
|
|
||||||
'''
|
|
||||||
try:
|
|
||||||
conn = httplib.HTTPConnection("127.0.0.1:%d" % PORT)
|
|
||||||
conn.request("QUIT", "/")
|
|
||||||
conn.getresponse()
|
|
||||||
except Exception as error:
|
|
||||||
LOG.exception(error)
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
|
|
||||||
''' Called to start the webservice.
|
|
||||||
'''
|
|
||||||
LOG.info("--->[ webservice/%s ]", PORT)
|
|
||||||
|
|
||||||
try:
|
|
||||||
server = HttpServer(('127.0.0.1', PORT), requestHandler)
|
|
||||||
server.serve_forever()
|
|
||||||
except Exception as error:
|
|
||||||
|
|
||||||
if '10053' not in error: # ignore host diconnected errors
|
|
||||||
LOG.exception(error)
|
|
||||||
|
|
||||||
LOG.info("---<[ webservice ]")
|
|
||||||
|
|
||||||
|
|
||||||
class HttpServer(BaseHTTPServer.HTTPServer):
|
|
||||||
|
|
||||||
''' Http server that reacts to self.stop flag.
|
|
||||||
'''
|
|
||||||
def serve_forever(self):
|
|
||||||
|
|
||||||
''' Handle one request at a time until stopped.
|
|
||||||
'''
|
|
||||||
self.stop = False
|
|
||||||
|
|
||||||
while not self.stop:
|
|
||||||
self.handle_request()
|
|
||||||
|
|
||||||
|
|
||||||
class requestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
|
|
||||||
|
|
||||||
''' Http request handler. Do not use LOG here,
|
|
||||||
it will hang requests in Kodi > show information dialog.
|
|
||||||
'''
|
|
||||||
|
|
||||||
def log_message(self, format, *args):
|
|
||||||
|
|
||||||
''' Mute the webservice requests.
|
|
||||||
'''
|
|
||||||
pass
|
|
||||||
|
|
||||||
def do_QUIT(self):
|
|
||||||
|
|
||||||
''' send 200 OK response, and set server.stop to True
|
|
||||||
'''
|
|
||||||
self.send_response(200)
|
|
||||||
self.end_headers()
|
|
||||||
self.server.stop = True
|
|
||||||
|
|
||||||
def get_params(self):
|
|
||||||
|
|
||||||
''' Get the params
|
|
||||||
'''
|
|
||||||
try:
|
|
||||||
path = self.path[1:]
|
|
||||||
|
|
||||||
if '?' in path:
|
|
||||||
path = path.split('?', 1)[1]
|
|
||||||
|
|
||||||
params = dict(parse_qsl(path))
|
|
||||||
except Exception:
|
|
||||||
params = {}
|
|
||||||
|
|
||||||
return params
|
|
||||||
|
|
||||||
def do_HEAD(self):
|
|
||||||
|
|
||||||
''' Called on HEAD requests
|
|
||||||
'''
|
|
||||||
self.send_response(200)
|
|
||||||
self.end_headers()
|
|
||||||
|
|
||||||
def do_GET(self):
|
|
||||||
|
|
||||||
''' Return plugin path
|
|
||||||
'''
|
|
||||||
try:
|
|
||||||
params = self.get_params()
|
|
||||||
|
|
||||||
if not params or params.get('Id') is None:
|
|
||||||
raise IndexError("Incomplete URL format")
|
|
||||||
|
|
||||||
xbmc.log("[ webservice ] path: %s params: %s" % (str(self.path), str(params)), xbmc.LOGWARNING)
|
|
||||||
|
|
||||||
path = ("plugin://plugin.video.jellyfin?mode=play&id=%s&dbid=%s&filename=%s&transcode=%s"
|
|
||||||
% (params.get('Id'), params.get('KodiId'), params.get('Name'), params.get('transcode') or False))
|
|
||||||
|
|
||||||
self.send_response(200)
|
|
||||||
self.send_header('Content-type', 'text/html')
|
|
||||||
self.end_headers()
|
|
||||||
self.wfile.write(path)
|
|
||||||
|
|
||||||
except IndexError as error:
|
|
||||||
LOG.exception(error)
|
|
||||||
|
|
||||||
self.send_error(404, "Exception occurred: %s" % error)
|
|
||||||
|
|
||||||
except Exception as error:
|
|
||||||
LOG.exception(error)
|
|
||||||
|
|
||||||
self.send_error(500, "Exception occurred: %s" % error)
|
|
Loading…
Reference in a new issue