@@ -318,21 +318,21 @@ def goToMedia(self, media, **params):
318318 Parameters:
319319 media (:class:`~plexapi.media.Media`): Media object to navigate to.
320320 **params (dict): Additional GET parameters to include with the command.
321-
322- Raises:
323- :exc:`~plexapi.exceptions.Unsupported`: When no PlexServer specified in this object.
324321 """
325- if not self ._server :
326- raise Unsupported ('A server must be specified before using this command.' )
327322 server_url = media ._server ._baseurl .split (':' )
328- self . sendCommand ( 'mirror/details' , ** dict ( {
329- 'machineIdentifier' : self ._server .machineIdentifier ,
323+ command = {
324+ 'machineIdentifier' : media ._server .machineIdentifier ,
330325 'address' : server_url [1 ].strip ('/' ),
331326 'port' : server_url [- 1 ],
332327 'key' : media .key ,
333328 'protocol' : server_url [0 ],
334- 'token' : media ._server .createToken ()
335- }, ** params ))
329+ ** params ,
330+ }
331+ token = media ._server .createToken ()
332+ if token :
333+ command ["token" ] = token
334+
335+ self .sendCommand ("mirror/details" , ** command )
336336
337337 # -------------------
338338 # Playback Commands
@@ -488,12 +488,7 @@ def playMedia(self, media, offset=0, **params):
488488 representing the beginning (default 0).
489489 **params (dict): Optional additional parameters to include in the playback request. See
490490 also: https://github.com/plexinc/plex-media-player/wiki/Remote-control-API#modified-commands
491-
492- Raises:
493- :exc:`~plexapi.exceptions.Unsupported`: When no PlexServer specified in this object.
494491 """
495- if not self ._server :
496- raise Unsupported ('A server must be specified before using this command.' )
497492 server_url = media ._server ._baseurl .split (':' )
498493 server_port = server_url [- 1 ].strip ('/' )
499494
@@ -509,19 +504,24 @@ def playMedia(self, media, offset=0, **params):
509504 if mediatype == "audio" :
510505 mediatype = "music"
511506
512- playqueue = media if isinstance (media , PlayQueue ) else self ._server .createPlayQueue (media )
513- self . sendCommand ( 'playback/playMedia' , ** dict ( {
507+ playqueue = media if isinstance (media , PlayQueue ) else media ._server .createPlayQueue (media )
508+ command = {
514509 'providerIdentifier' : 'com.plexapp.plugins.library' ,
515- 'machineIdentifier' : self ._server .machineIdentifier ,
510+ 'machineIdentifier' : media ._server .machineIdentifier ,
516511 'protocol' : server_url [0 ],
517512 'address' : server_url [1 ].strip ('/' ),
518513 'port' : server_port ,
519514 'offset' : offset ,
520515 'key' : media .key or playqueue .selectedItem .key ,
521- 'token' : media ._server .createToken (),
522516 'type' : mediatype ,
523517 'containerKey' : '/playQueues/%s?window=100&own=1' % playqueue .playQueueID ,
524- }, ** params ))
518+ ** params ,
519+ }
520+ token = media ._server .createToken ()
521+ if token :
522+ command ["token" ] = token
523+
524+ self .sendCommand ("playback/playMedia" , ** command )
525525
526526 def setParameters (self , volume = None , shuffle = None , repeat = None , mtype = DEFAULT_MTYPE ):
527527 """ Set multiple playback parameters at once.
0 commit comments