mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-26 05:30:20 +00:00
Update timeline() to use server.query to include proper headers and timeout
This commit is contained in:
parent
457046f174
commit
b2c9a29d1e
2 changed files with 3 additions and 5 deletions
|
@ -93,10 +93,8 @@ class Client(object):
|
|||
})
|
||||
|
||||
def timeline(self):
|
||||
url = self.url('timeline/poll')
|
||||
params = {'wait':1, 'commandID':4}
|
||||
xml_text = requests.get(url, params=params, headers=BASE_HEADERS).text
|
||||
return ElementTree.fromstring(xml_text)
|
||||
return self.server.query('timeline/poll', params=params)
|
||||
|
||||
def isPlayingMedia(self):
|
||||
timeline = self.timeline()
|
||||
|
|
|
@ -74,12 +74,12 @@ class PlexServer(object):
|
|||
headers['X-Plex-Token'] = self.token
|
||||
return headers
|
||||
|
||||
def query(self, path, method=requests.get):
|
||||
def query(self, path, method=requests.get, **kwargs):
|
||||
global TOTAL_QUERIES
|
||||
TOTAL_QUERIES += 1
|
||||
url = self.url(path)
|
||||
log.info('%s %s', method.__name__.upper(), url)
|
||||
response = method(url, headers=self.headers(), timeout=TIMEOUT)
|
||||
response = method(url, headers=self.headers(), timeout=TIMEOUT, **kwargs)
|
||||
if response.status_code not in [200, 201]:
|
||||
codename = codes.get(response.status_code)[0]
|
||||
raise BadRequest('(%s) %s' % (response.status_code, codename))
|
||||
|
|
Loading…
Reference in a new issue