mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-21 19:23:05 +00:00
Add MyPlexAccount.ping()
to refresh authentication token (#1271)
* Add `MyPlexAccount.ping()` to refresh auth token * Test account ping
This commit is contained in:
parent
7f5cf76cbd
commit
253949c1fe
2 changed files with 14 additions and 0 deletions
|
@ -108,6 +108,7 @@ class MyPlexAccount(PlexObject):
|
|||
OPTOUTS = 'https://plex.tv/api/v2/user/{userUUID}/settings/opt_outs' # get
|
||||
LINK = 'https://plex.tv/api/v2/pins/link' # put
|
||||
VIEWSTATESYNC = 'https://plex.tv/api/v2/user/view_state_sync' # put
|
||||
PING = 'https://plex.tv/api/v2/ping'
|
||||
# Hub sections
|
||||
VOD = 'https://vod.provider.plex.tv' # get
|
||||
MUSIC = 'https://music.provider.plex.tv' # get
|
||||
|
@ -250,6 +251,15 @@ class MyPlexAccount(PlexObject):
|
|||
data = response.text.encode('utf8')
|
||||
return ElementTree.fromstring(data) if data.strip() else None
|
||||
|
||||
def ping(self):
|
||||
""" Ping the Plex.tv API.
|
||||
This will refresh the authentication token to prevent it from expiring.
|
||||
"""
|
||||
pong = self.query(self.PING)
|
||||
if pong is not None:
|
||||
return utils.cast(bool, pong.text)
|
||||
return False
|
||||
|
||||
def device(self, name=None, clientId=None):
|
||||
""" Returns the :class:`~plexapi.myplex.MyPlexDevice` that matches the name specified.
|
||||
|
||||
|
|
|
@ -361,3 +361,7 @@ def test_myplex_pin(account, plex):
|
|||
|
||||
def test_myplex_geoip(account):
|
||||
assert account.geoip(account.publicIP())
|
||||
|
||||
|
||||
def test_myplex_ping(account):
|
||||
assert account.ping()
|
||||
|
|
Loading…
Reference in a new issue