Posts: 1
Joined: Sep 2024
Reputation:
0
In Kodi app, there is a pretty nice feature about continue watching a specific tv show. It remember the episode i've watched, and next time when I choose "Continue Watching", it will start playback on next episode.
My question is how can i implement or achieve a feature like this through JSON-RPC API. I've tried some API but with no luck.
Posts: 1,401
Joined: Mar 2018
Reputation:
30
For a given TV Show you could read the playcount for each season. For the first non-played one you read playcount for each episode and continue with the first non-played one.
Posts: 1,401
Joined: Mar 2018
Reputation:
30
Thanks, I was hoping the method would somehow return back the next episode to play and/or the time position in the current played one.
Posts: 782
Joined: Aug 2009
Reputation:
178
roidy
Posting Freak
Posts: 782
2024-10-09, 17:50
(This post was last modified: 2024-10-09, 17:53 by roidy. Edited 1 time in total.)
Once have the list of TV Shows from the "GetInprogressTVShows " endpoint. Just iterate over all of the Shows and using the tvshowid run a json-rpc query using the "GetEpisodes" endpoint and the following params:-
VideoLibrary.GetEpisodes
tvshowid = the id from the show return from "GetInprogressTVShows"
sort = {'order': 'ascending', 'method': 'playcount'}
filter = {'field': 'inprogress', 'operator': 'true', 'value': ''}
limit = 1
This will return one single episode from the show that is either currently inprogress or the next episode to watch, then just assemble all the episodes into a list.
Posts: 54
Joined: Mar 2024
Reputation:
10
There are many ways to do this, and there is no specification to say what is correct or not, so if you are satisfied with the results then that is what matters.
Just pointing out some stuff that I came across previously when looking at the same thing. Personally this current discussion has led to some improvements in how I ended up doing it, with the following comments being an extension of that.
By not filtering for inprogress in the VideoLibrary.GetEpisodes, you will get pretty close to the generally expected result, but as originally described with filtering on inprogress, it would not have worked.
The implementation of videodb://inprogresstvshows/ gets the job done quickly, but it has limitation that make it not useful in a few scenarios, and any implementation that utilises VideoLibrary.GetInprogressTVShows will have the same limitations. There is also another issue that may not be immediately obvious - using VideoLibrary.GetInprogressTVShows and then VideoLibrary.GetEpisodes sorted by playcount implicitly relies on the order that the video database returns results for the episodes from a show, rather than the actual episode order or the watch order.
This means that the results of the VideoLibrary.GetEpisodes calls may or may not actually provide the correct next episode depending on a number of factors, including whether the order in which episodes were added to the video library matches the same order in which you are watching the episodes.
This is on top of the underlying issues with VideoLibrary.GetInprogressTVShows, which combined, can prove problematic if you are skipping episodes or seasons, or watching seasons or episodes out of order, or re-watching a show, or have special episodes in season 0, or have re-added/refreshed/replaced episodes, or simply just originally added episodes out of order in the video library.
You are using X + 1 calls, with X being the number of tvshows returned by VideoLibrary.GetInprogressTVShows. In order to get the next episode without assuming that the order of records from the underlying database query will match your watching order, you need to know the last episode that was played, so rather than X + 1 JSON-RPC calls, you will end up needing 2*X + 1 calls. In order to check tvshows that have previously been watched will require an additional 2*Y + 1 JSON-RPC calls, where Y is the number of watched tvshows returned by VideoLibrary.GetTVShows.
All of this ends up being slower than just using VideoLibrary.GetEpisodes but I guess whether or not these limitation are important to someone will vary depending on how they manage their video library, and also how they actually watch the shows contained in their library.