Skip to content

Instantly share code, notes, and snippets.

@mdemerson
Created February 4, 2022 04:21
Show Gist options
  • Save mdemerson/ec7f8a82629b1b44522132c8c56df248 to your computer and use it in GitHub Desktop.
Save mdemerson/ec7f8a82629b1b44522132c8c56df248 to your computer and use it in GitHub Desktop.
Small script that adds spoiler tags to existing unwatched TV shows
#!/usr/bin/env python3
# Small script that adds spoiler tags to existing unwatched TV shows
# Relies on:
# https://github.com/pkkid/python-plexapi
# https://gist.github.com/JonnyWong16/ea8f51f674fdb4ebf4e47e53cd1a10e5
# Imports
import os
from plexapi.server import PlexServer
# Variables
baseurl = 'http://plexurl:32400'
token = 'plextoken'
# Create session
plex = PlexServer(baseurl, token)
# Blur all unwatched episodes and add "** Spoler Alert **" to summaries
tv = plex.library.section("TV")
shows = tv.all()
for show in shows:
print(show.title)
for season in show.seasons():
season_num = int(season.index)
if season_num == 0:
continue
for episode in season.episodes():
episode_num = int(episode.index)
if episode_num == 0:
continue
if episode.isWatched:
print(f' {show.title}\'s episode: {episode.title} has been watched, no change to make.')
else:
print(f' adding spoiler features for {show.title}\'s episode: {episode.title}.')
os.system(f'python3 /config/scripts/hide_episode_spoilers.py --rating_key {episode.ratingKey} --blur 25 --summary_prefix "** Spoilers Below **"')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment