2017-01-03 00:07:24 +11:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
###############################################################################
|
2017-12-10 00:35:08 +11:00
|
|
|
from logging import getLogger
|
2017-01-03 00:07:24 +11:00
|
|
|
from threading import Thread
|
|
|
|
from urlparse import parse_qsl
|
|
|
|
|
|
|
|
from pickler import pickle_me, Playback_Successful
|
2018-01-11 06:14:05 +11:00
|
|
|
import playback
|
2017-09-10 23:09:32 +10:00
|
|
|
from context_entry import ContextMenu
|
2017-05-17 18:10:14 +10:00
|
|
|
import state
|
2017-01-03 00:07:24 +11:00
|
|
|
|
|
|
|
###############################################################################
|
2018-01-07 01:19:12 +11:00
|
|
|
|
|
|
|
LOG = getLogger("PLEX." + __name__)
|
2017-01-03 00:07:24 +11:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
|
|
|
|
class Playback_Starter(Thread):
|
|
|
|
"""
|
|
|
|
Processes new plays
|
|
|
|
"""
|
|
|
|
def triage(self, item):
|
2017-03-14 07:39:07 +11:00
|
|
|
_, params = item.split('?', 1)
|
2017-01-03 00:07:24 +11:00
|
|
|
params = dict(parse_qsl(params))
|
2017-03-14 07:39:07 +11:00
|
|
|
mode = params.get('mode')
|
2018-01-07 01:19:12 +11:00
|
|
|
LOG.debug('Received mode: %s, params: %s', mode, params)
|
2018-01-11 06:14:05 +11:00
|
|
|
if mode == 'play':
|
2018-01-29 03:21:28 +11:00
|
|
|
playback.playback_triage(plex_id=params.get('plex_id'),
|
|
|
|
plex_type=params.get('plex_type'),
|
|
|
|
path=params.get('path'))
|
2018-01-11 06:14:05 +11:00
|
|
|
elif mode == 'plex_node':
|
2018-01-29 03:21:28 +11:00
|
|
|
playback.process_indirect(params['key'], params['offset'])
|
2018-01-11 06:14:05 +11:00
|
|
|
elif mode == 'context_menu':
|
2018-02-16 05:47:01 +11:00
|
|
|
ContextMenu(kodi_id=params['kodi_id'],
|
|
|
|
kodi_type=params['kodi_type'])
|
|
|
|
|
2017-01-03 00:07:24 +11:00
|
|
|
def run(self):
|
2018-01-07 01:19:12 +11:00
|
|
|
queue = state.COMMAND_PIPELINE_QUEUE
|
|
|
|
LOG.info("----===## Starting Playback_Starter ##===----")
|
2017-01-03 00:07:24 +11:00
|
|
|
while True:
|
|
|
|
item = queue.get()
|
|
|
|
if item is None:
|
2017-05-17 18:09:50 +10:00
|
|
|
# Need to shutdown - initiated by command_pipeline
|
2017-01-03 00:07:24 +11:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
self.triage(item)
|
|
|
|
queue.task_done()
|
2018-01-07 01:19:12 +11:00
|
|
|
LOG.info("----===## Playback_Starter stopped ##===----")
|