From 7c7567742788631eb771a1ec292b7fbe6eca306c Mon Sep 17 00:00:00 2001 From: Moe Fwacky Date: Sun, 9 Jan 2022 02:41:18 -0800 Subject: [PATCH] Added input option to last episode selection In the --last-episode/-le function to manually set the last scheduled episode in the database for any show or playlist, the ability to use the unique plex id (ratingKey in the API, or the unique digits near the end (before the Plex Token) of the URL when going from File Info -> View XML Data on an episode page within Plex) instead of season and episode numbers. This better allows support for this function with Playlists, which may have multiple files with the same season and episode numbers. --- both-dir/PseudoChannel.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/both-dir/PseudoChannel.py b/both-dir/PseudoChannel.py index 5793970..9c960b8 100644 --- a/both-dir/PseudoChannel.py +++ b/both-dir/PseudoChannel.py @@ -1608,16 +1608,23 @@ class PseudoChannel(): showData = self.db.get_shows(showName) #print("SHOW SELECTED: "+showData[3]) if(showData is not None): - print("Enter the season and episode numbers for the 'last episode' (episode previous to the episode you wish to be scheduled on next -g run") - sNo = input("Season Number: ") - eNo = input("Episode Number: ") - episodeData = self.db.get_episode_from_season_episode(showName,sNo,eNo) - if(episodeData is not None): - print("Setting "+episodeData[7]+" - "+episodeData[3]+" S"+str(episodeData[6])+"E"+str(episodeData[5])+" as the Last Episode in the Shows Database") + print("Enter the 'ratingKey' value (also integer following '/library/metadata/' in the URL) of the 'last episode' from the API, or leave blank to select by season and episode number (does not work for Playlists).") + plexID = input('/library/metadata/') + episodeData = self.db.get_episode_from_plexMediaID('/library/metadata/'+plexID) + if episodeData != None: + print("Setting "+episodeData[7]+" - "+episodeData[3]+" S"+str(episodeData[6])+"E"+str(episodeData[5])+" as the Last Episode in the Shows Database for "+showName) self.db.update_shows_table_with_last_episode(episodeData[7], episodeData[8]) else: - print("ERROR: EPISODE NOT FOUND IN PSEUDO CHANNEL DATABASE") - sys.exit(1) + print("Enter the season and episode numbers for the 'last episode' (episode previous to the episode you wish to be scheduled on next -g run") + sNo = input("Season Number: ") + eNo = input("Episode Number: ") + episodeData = self.db.get_episode_from_season_episode(showName,sNo,eNo) + if(episodeData is not None): + print("Setting "+episodeData[7]+" - "+episodeData[3]+" S"+str(episodeData[6])+"E"+str(episodeData[5])+" as the Last Episode in the Shows Database for "+showName) + self.db.update_shows_table_with_last_episode(episodeData[7], episodeData[8]) + else: + print("ERROR: EPISODE NOT FOUND IN PSEUDO CHANNEL DATABASE") + sys.exit(1) else: print("ERROR: SHOW NOT FOUND IN PSEUDO CHANNEL DATABASE") sys.exit(1)