-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplex.py
31 lines (23 loc) · 878 Bytes
/
plex.py
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
from bs4 import BeautifulSoup
import requests, json
from tqdm import tqdm
from plexapi.server import PlexServer
from plexapi.myplex import MyPlexAccount, MyPlexUser, MyPlexAccount
from plexapi.library import Library
email = "SET_EMAIL_HERE"
data = open('plex.json','r').read().split("\n")
data = list(filter(None, data))
servers = []
for x in data:
servers.append(json.loads(x)['ip_str'])
for server in tqdm(servers):
try:
page = requests.get(f'http://{server}:8181/settings')
soup = BeautifulSoup(page.content, 'html.parser')
token = soup.find("input", {"id": "pms_token"})["value"]
plex = PlexServer(f'http://{server}:32400', token)
plex.myPlexAccount().inviteFriend(email, plex, plex.library.sections())
except:
print(f'Failed to access {server}')
else:
print(f'Successfully accessed {server}')