Skip to content

Commit

Permalink
CHG: remove playqueues-creation - because not working now
Browse files Browse the repository at this point in the history
player is working well without this capability
  • Loading branch information
risiko79 committed May 11, 2023
1 parent 226d0a0 commit ee4241d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
23 changes: 22 additions & 1 deletion mopidy_plex/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand Down
9 changes: 7 additions & 2 deletions mopidy_plex/httpd.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion mopidy_plex/register.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -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',
Expand Down

0 comments on commit ee4241d

Please sign in to comment.