Create plex_allow_sync.py

This commit is contained in:
blacktwin 2017-09-18 15:27:31 -04:00 committed by GitHub
parent 522d9a6e7d
commit 05af0efecb

View File

@ -0,0 +1,22 @@
"""
Allow syncing for users
"""
import requests
from plexapi.server import PlexServer
PLEX_URL = 'http://localhost:32400'
PLEX_TOKEN = 'xxxx'
plex = PlexServer(PLEX_URL, PLEX_TOKEN)
USER_IGNORE = ['username']
user_lst = [str(user.id) for user in plex.myPlexAccount().users() if user.title not in USER_IGNORE]
payload = {'X-Plex-Token': PLEX_TOKEN,
'allowSync': 0}
for user_id in user_lst:
r = requests.put('http://plex.tv/api/friends/' + user_id, params=payload)
print(r.status_code)