Skip to content

Instantly share code, notes, and snippets.

@blacktwin
Last active May 30, 2019 16:42
Show Gist options
  • Save blacktwin/3752a76fa0b3fc6d19e842af7b812184 to your computer and use it in GitHub Desktop.
Save blacktwin/3752a76fa0b3fc6d19e842af7b812184 to your computer and use it in GitHub Desktop.
Refresh the next episode of show once current episode is watched.
'''
Refresh the next episode of show once current episode is watched.
Check PlexPy's Watched Percent in PlexPy > Settings > General
1. PlexPy > Settings > Notification Agents > Scripts > Bell icon:
[X] Notify on watched
2. PlexPy > Settings > Notification Agents > Scripts > Gear icon:
Enter the "Script folder" where you save the script.
Watched: refresh_next_episode.py
Save
3. PlexPy > Settings > Notifications > Script > Script Arguments:
{show_name} {episode_num00} {season_num00}
'''
import sys
from plexapi.server import PlexServer
# pip install plexapi
baseurl = 'http://localhost:32400'
token = 'XXXXXX' # Plex Token
plex = PlexServer(baseurl, token)
show_name = sys.argv[1]
next_ep_num = int(sys.argv[2])
season_num = int(sys.argv[3])
TV_LIBRARY = 'My TV Shows' # Name of your TV Shows library
current_season = season_num - 1
# Get all seasons from Show
all_seasons = plex.library.section(TV_LIBRARY).get(show_name).seasons()
try:
# Get all episodes from current season of Show
all_eps = all_seasons[current_season].episodes()
# Refresh the next episode
all_eps[next_ep_num].refresh()
except IndexError:
try:
# End of season go to next season
all_eps = all_seasons[season_num].episodes()
# Refresh the next season's first episode
all_eps[0].refresh()
except IndexError:
print('End of series')
@Hellowlol
Copy link

This was actually a pretty good idea. I'll modify this so it refreshes the show if next do is still missing still missing I'll force download via sickrage

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