2018-07-14 06:36:33 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
Plex-GetToken is a simple method to retrieve a Plex account token.
|
|
|
|
"""
|
2024-02-04 18:49:55 +00:00
|
|
|
from getpass import getpass
|
2024-02-17 22:34:43 +00:00
|
|
|
from plexapi.exceptions import TwoFactorRequired
|
2018-07-14 06:36:33 +00:00
|
|
|
from plexapi.myplex import MyPlexAccount
|
2018-07-13 14:08:15 +00:00
|
|
|
|
|
|
|
username = input("Plex username: ")
|
2024-02-04 18:49:55 +00:00
|
|
|
password = getpass("Plex password: ")
|
2018-07-13 14:08:15 +00:00
|
|
|
|
2024-02-17 22:34:43 +00:00
|
|
|
try:
|
|
|
|
account = MyPlexAccount(username, password)
|
|
|
|
except TwoFactorRequired:
|
|
|
|
code = input("Plex 2FA code: ")
|
|
|
|
account = MyPlexAccount(username, password, code=code)
|
|
|
|
|
2019-06-03 02:38:24 +00:00
|
|
|
print(account.authenticationToken)
|