2017-02-25 05:12:24 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from getpass import getpass
|
|
|
|
from plexapi.exceptions import BadRequest
|
2017-02-25 05:17:53 +00:00
|
|
|
from plexapi.myplex import MyPlexAccount, MyPlexResource
|
2017-02-25 05:12:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2017-02-25 05:23:20 +00:00
|
|
|
print('List Plex Tokens')
|
|
|
|
print('----------------')
|
|
|
|
print('This is a simple utility to fetch and list all known Plex Server')
|
|
|
|
print('tokens your plex.tv account has access to. Because this information')
|
|
|
|
print('comes from the plex.tv website, we need to ask for your username')
|
|
|
|
print('and password. Alternatively, if you do not wish to enter your login')
|
|
|
|
print('information below, you can retrieve the same information from plex.tv')
|
|
|
|
print('directly at the URL: %s\n' % MyPlexResource.key)
|
2017-02-25 05:12:24 +00:00
|
|
|
username = input('What is your plex.tv username: ')
|
|
|
|
password = getpass('What is your plex.tv password: ')
|
|
|
|
try:
|
2017-02-25 05:23:20 +00:00
|
|
|
count = 0; print()
|
|
|
|
for resource in MyPlexAccount(username, password).resources():
|
2017-02-25 05:12:24 +00:00
|
|
|
if resource.accessToken:
|
|
|
|
print('%s %s' % (resource.accessToken, resource.name))
|
|
|
|
count += 1
|
|
|
|
if not count:
|
|
|
|
print('Did not found any resources on your account.')
|
|
|
|
except BadRequest as err:
|
|
|
|
print('Unable to login to plex.tv: %s' % err)
|