@@ -206,7 +206,7 @@ def _myPlexClientPorts(self):
206
206
ports [device .clientIdentifier ] = device .connections [0 ].split (':' )[- 1 ]
207
207
return ports
208
208
except Exception as err :
209
- log .warn ('Unable to fetch client ports from myPlex: %s' , err )
209
+ log .warning ('Unable to fetch client ports from myPlex: %s' , err )
210
210
return ports
211
211
212
212
def clients (self ):
@@ -216,11 +216,13 @@ def clients(self):
216
216
for elem in self .query ('/clients' ):
217
217
port = elem .attrib .get ('port' )
218
218
if not port :
219
- log .warn ('%s did not advertise a port, checking plex.tv.' , elem .attrib .get ('name' ))
219
+ log .warning ('%s did not advertise a port, checking plex.tv.' , elem .attrib .get ('name' ))
220
220
ports = self ._myPlexClientPorts () if ports is None else ports
221
221
port = ports .get (elem .attrib .get ('machineIdentifier' ))
222
222
baseurl = 'http://%s:%s' % (elem .attrib ['host' ], port )
223
- items .append (PlexClient (baseurl = baseurl , server = self , data = elem , connect = False ))
223
+ items .append (PlexClient (baseurl = baseurl , server = self ,
224
+ token = self ._token , data = elem , connect = False ))
225
+
224
226
return items
225
227
226
228
def client (self , name ):
@@ -232,15 +234,10 @@ def client(self, name):
232
234
Raises:
233
235
:class:`~plexapi.exceptions.NotFound`: Unknown client name
234
236
"""
235
- for elem in self .query ('/clients' ):
236
- if elem .attrib .get ('name' ).lower () == name .lower ():
237
- port = elem .attrib .get ('port' )
238
- if not port :
239
- log .warn ('%s did not advertise a port, checking plex.tv.' , elem .attrib .get ('name' ))
240
- ports = self ._myPlexClientPorts ()
241
- port = ports .get (elem .attrib .get ('machineIdentifier' ))
242
- baseurl = 'http://%s:%s' % (elem .attrib ['host' ], port )
243
- return PlexClient (baseurl = baseurl , server = self , data = elem )
237
+ for client in self .clients ():
238
+ if client and client .title == name :
239
+ return client
240
+
244
241
raise NotFound ('Unknown client name: %s' % name )
245
242
246
243
def createPlaylist (self , title , items ):
@@ -345,8 +342,8 @@ def query(self, key, method=None, headers=None, timeout=None, **kwargs):
345
342
if response .status_code not in (200 , 201 ):
346
343
codename = codes .get (response .status_code )[0 ]
347
344
errtext = response .text .replace ('\n ' , ' ' )
348
- log .warn ('BadRequest (%s) %s %s; %s' % (response .status_code , codename , response .url , errtext ))
349
- raise BadRequest ('(%s) %s; %s' % (response .status_code , codename , errtext ))
345
+ log .warning ('BadRequest (%s) %s %s; %s' % (response .status_code , codename , response .url , errtext ))
346
+ raise BadRequest ('(%s) %s; %s %s ' % (response .status_code , codename , response . url , errtext ))
350
347
data = response .text .encode ('utf8' )
351
348
return ElementTree .fromstring (data ) if data .strip () else None
352
349
0 commit comments