Thanks for confirming.
I wrote the utility function needed to continue Plex shows in HA (with quite a bit of flexibility and fallback mechanisms), things seem to work very well. I just need to clear it with work to ensure I’m allowed to share code.
Notes:
- Only available with TV shows
- Below continuation modes can only work in either Show or Season contexts
- If user specified show, season and Episode, then continuation logic doesn’t trigger
This is the current media_id “API” (“Futurama” example):
media_id: { "library_name": "tv shows", "show_name": "futurama" }
Proposed alterations includes new keyword: "_continue"
(the leading underscore is added to emphasize that it’s not a Plex media_api field; can be removed if undesirable).
For example (cont. “Futurama” example)::
media_id: { "library_name": "tv shows", "show_name": "futurama", "_continue": "deck|unfinished_last|unwatched_first" }
This will attempt to continue Futurama from deck; if it’s not on deck, it will look for the last part-way watched episode; if no such episodes are found, it will attempt to continue the first unwatched episode; if it’s not found it will play from the beginning.
Following is a more detailed description:
The following continuation modes are supported:
1. Deck: resumes media off the library deck
- Requires:
- library or section object
- show name
- Optional: season number
- Parameters: first/last
2. Unfinished (episodes that were watched partway through)
- Requires: show or season object
- Parameters: first/last
3. Unwatched
- Requires: show or season object
- Parameters: first/last
4. Watched
- Requires: show or season object
- Parameters: first/last
Each mechanism above can function as a fallback in case the prior mechanism
fails to find a suitable episode. Fallbacks are delimited by a "|".
If all mechanisms fail, the show will start from the beginning.
Mechanisms may also be parameterized to get the 'first' or 'last' element
among the results (e.g. first unwatched, last unfinished). Parameters are
delimited by an "_". Default is 'first'.
Example:
Let's assume the following complex continuation mechanism is desired:
Resume show from deck, and if it's missing then
resume last unfinished episode, and if it's missing then
resume first unwatched episode, and if it's missing then
start show from the beginning
Resultant continuation query:
... "_continue": "deck|unfinished_last|unwatched_first" ...
While I was there, I also added support for Plex parameter "continuous": 1
in order to have the show continue playing on from the selected episode.
I’ll update this thread once the code is ready for review. It’s only ~40 lines of code but I don’t know HA style guidelines (using vim, no visual code) and surely there will be nitpicks. Plus I just slapped this sloppy piece together.
Do you review HA code submissions, @jjlawren?