Open mainTAP opened 1 year ago
Try using proxyThroughServer()
.
>>> import plexapi
>>> from plexapi.server import PlexServer
>>> baseurl = 'http://SERVERIP:32400'
>>> plex = PlexServer(baseurl)
>>> client = plex.client("HTPC")
>>> client.proxyThroughServer()
>>> client.timeline
Thank you, using the client.proxyThroughServer() does help and it's able to show the timeline. Unfortunately, though, the client still cannot be controlled :
>>> client = plex.client("HTPC")
>>> client
<PlexClient:http://127.0.0.1:324:HTPC>
>>> client.proxyThroughServer()
>>> client.timeline
<ClientTimeline:25410>
>>> client.pause()
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='SERVERIP', port=32400): Read timed out. (read timeout=30)
Just to add that when adding the mtype='music' to the command ( as the playing media was music ), the playback does actually pause, but the command still hangs and excepts with the same exception :
>>> client.pause(mtype='music')
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='SERVERIP', port=32400): Read timed out. (read timeout=30)
I also have issues with retrieving client.isPlayingMedia() status ( and also timeline ) for the HTPC client when the client is freshly restarted and the media playback is initiated from the client itself, not via Plex companion / API . The client is listed but isPlayingMedia returns False. The dashboard in a Plex app shows the client playing the media and also the PlexServer.sessions() returns that session but not via the client itself.
Once there is connection to the client via Plex companion ( for instance Plex for MacOS,from the cast icon selecting the HTPC client ) even while that media is still being played at the HTPC client, once it connects, the API starts to recognising the client that it plays the media.
Once I disconnected from HTPC in the Plex for Mac app, the API still recognizing the client playing media, but once the playback is stopped and timeline cleared. The next media playback won't be recognised by the API until I connect via a Plex app to control HTPC.
Describe the Bug
When connecting to a HTPC (windows,1.50.1.4014) client, the API cannot connect properly as it retrieves its IP as 127.0.0.1 instead of its real IP. Other clients like Plexamp or Plex for mac work fine.
Code Snippets
Expected Behavior
To be able to connect to HTPC client and control it
Additional Context
Retrieving the clients from the server via SERVERIP:32400/clients shows the HTPC twice, once with 127.0.0.1 and also one with IP of the server ( rather than the IP of the actual client ). If I iterate over the plex.clients() and use the instance with the server's IP address, I'm able to retrieve the timeline but can't control the client like client.pause() and get timeout error : requests.exceptions.ReadTimeout: HTTPConnectionPool(host='SERVERIP', port=32400): Read timed out. (read timeout=30)
Operating System and Version
Debian ( PlexAPI ) , Ubuntu ( Plex Server ) , Windows 11 ( Plex HTPC )
Plex Media Server Version
1.32.7.7621
Python Version
3.9.2
PlexAPI Version
4.15.5