forked from pushingkarmaorg/python-plexapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplex-refreshtoken.py
More file actions
34 lines (27 loc) · 909 Bytes
/
plex-refreshtoken.py
File metadata and controls
34 lines (27 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
"""
Plex-RefreshToken is a simple method to refresh a Plex account token by pinging Plex.tv.
"""
import argparse
import plexapi
from plexapi.myplex import MyPlexAccount
def refresh_token(token):
"""Refresh the Plex authentication token."""
account = MyPlexAccount(token=token)
if account.ping():
print("Plex.tv authentication token refreshed successfully.")
else:
print("Failed to refresh Plex.tv authentication token.")
exit(1)
if __name__ == "__main__": # noqa: C901
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
"--token",
help="Plex.tv authentication token",
default=plexapi.CONFIG.get("auth.server_token"),
)
args = parser.parse_args()
if not args.token:
print("No Plex.tv authentication token provided.")
exit(1)
refresh_token(args.token)