mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-13 00:32:58 -07:00
Update Plex.tv signin to /api/v2
This commit is contained in:
parent
eeff665680
commit
e2c2f66e97
2 changed files with 17 additions and 8 deletions
|
@ -73,12 +73,14 @@ class HTTPHandler(object):
|
|||
def make_request(self,
|
||||
uri=None,
|
||||
headers=None,
|
||||
data=None,
|
||||
request_type='GET',
|
||||
output_format='raw',
|
||||
return_type=False,
|
||||
no_token=False,
|
||||
timeout=None,
|
||||
callback=None):
|
||||
callback=None,
|
||||
**request_kwargs):
|
||||
"""
|
||||
Handle the HTTP requests.
|
||||
|
||||
|
@ -86,11 +88,13 @@ class HTTPHandler(object):
|
|||
"""
|
||||
|
||||
self.uri = str(uri)
|
||||
self.data = data
|
||||
self.request_type = request_type.upper()
|
||||
self.output_format = output_format.lower()
|
||||
self.return_type = return_type
|
||||
self.callback = callback
|
||||
self.timeout = timeout or self.timeout
|
||||
self.request_kwargs = request_kwargs
|
||||
|
||||
if self.request_type not in self.valid_request_types:
|
||||
logger.debug("HTTP request made but unsupported request type given.")
|
||||
|
@ -149,7 +153,8 @@ class HTTPHandler(object):
|
|||
def _http_requests_urllib3(self, url, session):
|
||||
"""Request the data from the url"""
|
||||
try:
|
||||
r = session.request(self.request_type, url, headers=self.headers, timeout=self.timeout)
|
||||
r = session.request(self.request_type, url, headers=self.headers, fields=self.data,
|
||||
timeout=self.timeout, **self.request_kwargs)
|
||||
except IOError as e:
|
||||
if not self._silent:
|
||||
logger.warn("Failed to access uri endpoint %s with error %s" % (self.uri, e))
|
||||
|
|
|
@ -164,16 +164,20 @@ class PlexTV(object):
|
|||
headers=headers)
|
||||
|
||||
def get_plex_auth(self, output_format='raw'):
|
||||
uri = '/users/sign_in.xml'
|
||||
base64string = base64.b64encode(('%s:%s' % (self.username, self.password)).encode('utf-8'))
|
||||
headers = {'Content-Type': 'application/xml; charset=utf-8',
|
||||
'Authorization': 'Basic %s' % base64string.decode('utf-8')}
|
||||
uri = '/api/v2/users/signin'
|
||||
headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
'Accept': 'application/xml'}
|
||||
data = {'login': self.username,
|
||||
'password': self.password,
|
||||
'rememberMe': True}
|
||||
|
||||
request = self.request_handler.make_request(uri=uri,
|
||||
request_type='POST',
|
||||
headers=headers,
|
||||
data=data,
|
||||
output_format=output_format,
|
||||
no_token=True)
|
||||
no_token=True,
|
||||
encode_multipart=False)
|
||||
|
||||
return request
|
||||
|
||||
|
@ -184,7 +188,7 @@ class PlexTV(object):
|
|||
try:
|
||||
xml_head = plextv_response.getElementsByTagName('user')
|
||||
if xml_head:
|
||||
user = {'auth_token': xml_head[0].getAttribute('authenticationToken'),
|
||||
user = {'auth_token': xml_head[0].getAttribute('authToken'),
|
||||
'user_id': xml_head[0].getAttribute('id')
|
||||
}
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue