diff --git a/mopidy_plex/helper.py b/mopidy_plex/helper.py index 38aa069..722757e 100644 --- a/mopidy_plex/helper.py +++ b/mopidy_plex/helper.py @@ -77,7 +77,7 @@ def __init__(self, config:dict=None, session=None): token = self._plexaccount.authenticationToken - _plexserver = None + _plexserver:PlexServer = None self._plexserver = None devices = self._plexaccount.devices() for dev in devices: @@ -288,6 +288,27 @@ def refreshPlayQueue(self, params:dict): for item in q.items: uris.append('plex:track:%s' % item.ratingKey) return self._refreshPlayQueue(uris) + + def createPlayQueue(self, params:dict): + plex_key = params.get('key',None) + if plex_key is None: + return False + plex_items = self._plexserver.fetchItems(ekey=plex_key) + + q = PlexPlayQueue.create(server = self._plexserver, items=plex_items, + repeat=int(params.get('repeat','0')), + shuffle=int(params.get('shuffle','0')) + ) + self._playingInfos['playQueue'] = q + uris = [] + first_track_id = None + for item in q.items: + if first_track_id is None: + first_track_id = str(item.ratingKey) + uris.append('plex:track:%s' % item.ratingKey) + if self._refreshPlayQueue(uris): + return self._skipTo(first_track_id) + return False def _refreshPlayQueue(self, uris:array): tl_tracks = self._tracklist.get_tl_tracks().get() diff --git a/mopidy_plex/httpd.py b/mopidy_plex/httpd.py old mode 100755 new mode 100644 index 84ba7cf..45158bf --- a/mopidy_plex/httpd.py +++ b/mopidy_plex/httpd.py @@ -13,7 +13,10 @@ logger = logging.getLogger(__name__) -#plex protocol see https://github.com/plexinc/plex-media-player/wiki/Remote-control-API +# plex protocol see +# https://github.com/plexinc/plex-media-player/wiki/Remote-control-API +# https://github.com/Arcanemagus/plex-api/wiki/Plex-Web-API-Overview +# https://github.com/Arcanemagus/plex-api/wiki/Media-Player class PlexClientRequestHandler(BaseHTTPRequestHandler): protocol_version = 'HTTP/1.1' @@ -55,7 +58,7 @@ def _getPlayerCapabilities(self): resp += ' title="%s"' % getName(h) resp += ' protocol="plex"' resp += ' protocolVersion="1"' - resp += ' protocolCapabilities="timeline,playback,playqueues,playqueues-creation"' + resp += ' protocolCapabilities="timeline,playback,playqueues"' #resp += ' protocolCapabilities="timeline,playback,mirror,playqueues,playqueues-creation"' resp += ' machineIdentifier="%s"' % getIdentifier(h) resp += ' product="%s"' % getProduct(h) @@ -169,6 +172,8 @@ def answer_request(self): self._handleResult(MPH.get().skipTo(params)) elif request_path == "player/playback/refreshPlayQueue": self._handleResult(MPH.get().refreshPlayQueue(params)) + #elif request_path == "player/playback/createPlayQueue": + # self._handleResult(MPH.get().createPlayQueue(params)) TODO: not working else: logger.warning("unknown request: %s %s" % (request_path, params_org)) self.response("",code=HTTPStatus.NOT_IMPLEMENTED) # 501 Not Implemented (en-US) diff --git a/mopidy_plex/register.py b/mopidy_plex/register.py old mode 100755 new mode 100644 index a54731c..fe2be32 --- a/mopidy_plex/register.py +++ b/mopidy_plex/register.py @@ -31,11 +31,12 @@ def __init__(self): self.client_data+= "Product: %s\r\n" % getProduct(headers) self.client_data+= "Protocol: plex\r\n" self.client_data+= "Protocol-Version: 1\r\n" - self.client_data+= "Protocol-Capabilities: timeline,playback,playqueues,playqueues-creation\r\n" + self.client_data+= "Protocol-Capabilities: timeline,playback,playqueues\r\n" #self.client_data+= "Protocol-Capabilities: timeline,mirror,playback,playqueues,playqueues-creation,provider-playback\r\n" self.client_data+= "Resource-Identifier: %s\r\n" % self.client_id self.client_data+= "Updated-At: %s\r\n" % int(time.time()) # self.client_data+= "Version: %s\r\n" % getVersion(headers) + self.client_data+= "Device-Class: stb\r\n" logger.debug("client data %s" % self.client_data) diff --git a/setup.py b/setup.py index 6eabed5..92c4639 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- from setuptools import find_packages, setup -__version__ = "0.3.1" +__version__ = "0.3.2" setup( name='Mopidy-Plex',