-
-
Save ReenigneArcher/ef0a93e657f05e15af66c860aa552486 to your computer and use it in GitHub Desktop.
Mark everything shared with guest account as unwatched.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding=utf8 | |
import sys | |
reload(sys) | |
sys.setdefaultencoding('utf8') #encoding incase item title has non ascii characters | |
from plexapi.server import PlexServer | |
from plexapi.server import CONFIG | |
import requests | |
# Edit these | |
PLEX_URL = '' | |
PLEX_TOKEN = '' | |
if not PLEX_URL: | |
PLEX_URL = CONFIG.data['auth'].get('server_baseurl') | |
if not PLEX_TOKEN: | |
PLEX_TOKEN = CONFIG.data['auth'].get('server_token') | |
# | |
sess = requests.Session() | |
sess.verify = False | |
plex = PlexServer(PLEX_URL, PLEX_TOKEN, session=sess) | |
guest = plex.myPlexAccount().user("Guest") | |
token = guest.get_token(plex.machineIdentifier) | |
guest_plex = PlexServer(PLEX_URL, token, session=sess) | |
guest_sections = guest_plex.library.sections() | |
for section in guest_sections: | |
if not section.title == "Music": #Skip Music library | |
print("Marking section: {} unwatched.".format(section.title)) | |
for items in section.search(unwatched=False): #only check files not unwatched | |
print("Marking item: {} unwatched.".format(items.title)) | |
items.markUnwatched() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uses config file if PLEX_URL and/or PLEX_TOKEN are not filled out. Skips Music library as those fail when marking unwatched. Encoding is UTF-8 as to handle special characters in file names better.