2021-03-14, 17:40
(2020-06-02, 11:01)DanCooper Wrote: First of all: The Kodi Interface (KI) does not access the Kodi database directly, but uses the JSON-RPC API (v10 ATM in KI): LinkI've noticed that the new API version didn't bring up any improvements regarding the case where you have a TV show spread over multiple paths. I was just thinking if it was possible to find the episode ID by some other way.
That means that i don't have access to tables or views like "episode_view" or "season_view".
If you want to test the API you can use the default Kodi webinterface. On the bottom right corner is a button with 3 dots and a "The Lab" menu. In the lab is an "API browser" that allows you to send any API call to check what Kodi sends back as information (and thus to the KI).
How the KI sync tv shows elements:
TV show:
TV season:
- Get a list of tv shows of a specific path
Code:List.Filter.Rule.TVShows.field = List.Filter.Fields.TVShows.path
List.Filter.Rule.TVShows.Operator = List.Filter.Operators.Is
List.Filter.Rule.TVShows.value = "smb://TVSHOW_PATH"Code:VideoLibrary.GetTVShows(filter)
- If the result is exactly 1 entry than the KI uses that ID to sync.
TV episode:
- Get the tv show ID (see above).
- Get a list of all seasons of a specific tv show by tv show ID
Code:VideoLibrary.GetSeasons(ShowID)
- Filter the results by season number.
- If now the result is exactly 1 than use that season ID to sync.
- Get the tv show ID (see above).
- Get a list of episodes with ShowID and path filter
Code:filter = New List.Filter.EpisodesAnd
filterRule_Path.field = List.Filter.Fields.Episodes.path
filterRule_Path.Operator = List.Filter.Operators.Is
filterRule_Path.value = "smb://EPISODE_PATH"
filter.and.Add(filterRule_Path)
filterRule_Filename.field = List.Filter.Fields.Episodes.filename
filterRule_Filename.Operator = List.Filter.Operators.Is
filterRule_Filename.value = "filename.ext"
filter.and.Add(filterRule_Filename)Code:VideoLibrary.GetEpisodes(filter, ShowID, Season#)
- If the result is exactly 1 than use this ID to sync.
If the result is more than one than try to filter by episode number (multi-episode handling)
For example, my Star Trek TNG episodes are on four different volumes on my NAS. I can get the TV Show ID from the API, it's '9'. Then, using the id as a parameter, get a full list of episodes with VideoLibrary.GetEpisodes. You get the labels, which you can then use to find out the correct episode ID (by just using the episode season+order number information you have in EMM) to use it in VideoLibrary.SetEpisodeDetails.