pkkid / python-plexapi

Python bindings for the Plex API.
BSD 3-Clause "New" or "Revised" License
1.14k stars 196 forks source link

Update plex.client #1414

Closed brannon-breau closed 3 months ago

brannon-breau commented 4 months ago

What is your feature request?

Can we get an update for plex.client so we could use the machine ID instead of name? currently Apple TV doesn't have the device name just "Apple TV" the change would allow someone to use the Machine ID when using the follow type of code.

cars = plex.library.section('Movies').get('Cars') client = plex.client("Michael's iPhone") client.playMedia(cars)

Are there any workarounds?

No response

Code Snippets

No response

Additional Context

No response

JonnyWong16 commented 4 months ago

client(name) is just a shortcut for clients() with a loop that searches for the name.

https://github.com/pkkid/python-plexapi/blob/bbdb2385834d285af215069818e3d240ad4ff953/plexapi/server.py#L424-L428

So you could just do something similar with your own loop.

CLIENT_IDENTIFIER = 'XXXXXXXXXX'

cars = plex.library.section('Movies').get('Cars')

for client in plex.clients():
    if client and client.machineIdentifier == CLIENT_IDENTIFIER:
        break
else:
    raise NotFound(f'Unknown client identifier: {CLIENT_IDENTIFIER}')

client.playMedia(cars)