Skip to content

Instantly share code, notes, and snippets.

@ReenigneArcher
Forked from blacktwin/mark_guest_unwatched.py
Last active July 26, 2020 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ReenigneArcher/ef0a93e657f05e15af66c860aa552486 to your computer and use it in GitHub Desktop.
Save ReenigneArcher/ef0a93e657f05e15af66c860aa552486 to your computer and use it in GitHub Desktop.
Mark everything shared with guest account as unwatched.
# 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()
@ReenigneArcher
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment