Passing data around a multi folder menu?
#1
Hi,

I'm currently developing and addon for Kodi 19. The goal of this addon is the following:
-Load a given json database of movies, shorts, tv shows... with the following structure:
[
{"type": "movie", "id": "001", "director": "Director1", "gender": "Gender1", "year": "2018", "title": "Movie1"},
{"type": "short", "id": "002", "director": "Director2", "gender": "Gender1", "year": "1961", "title": "Short1"},
{"type": "movie", "id": "003", "director": "Director2", "gender": "Gender2", "year": "2019", "title": "Movie2"},
...
]
-Show a top menu with the categories (Movies, Shorts, TV Shows...).
-When selecting each category filter the json grouping by categories and show a new menu listing all the possible filters (By gender, by director, by year).
-When selecting a filter, filter again the filtered json of previous step, this time grouping by the chosen filter and show another menu listing all the possible values found on the json for that filter (with the sample json, if filtering by movies and by year this menu would contain 2018 and 2019).
-Finally, when selecting (in this case) the year, show a final menu with all titles matching that year.

My problem is the following:
I'm using the xbmcplugin.addDirectoryItem function to create the menus. However this method ends the plugin everytime it creates a menu, and reruns it when choosing a new option, using the URL parameters to redirect to the correct menu, so the only data which is persistent is the parameters of the URL, and with a json with more than 500 movies, 200 TV shows and 50 shorts it cannot be passed as an URL parameter.

I'll try to show this with an example.

Ideal situation:
-Plugin runs.
-Loads the json file.
-Shows the menu (Movies, TV Shows, Shorts).
-I choose the Movies option.
-The plugin filters the huge json, returns only the group of movies and prints the filters menu (Director, Gender, Year).
-I choose the Year option.
-The plugin filters the group of movies by year, returns a group for each year found and prints the menu with each year.
-I select 2018.
-The plugin filters the group of movies for the year 2018 and prints their titles.

The problem is that the execution ends with each option I select, so I'm forced to do the following instead:

Current situation:
-Plugin runs.
-Shows the menu (Movies, TV Shows, Shorts).
-I choose the Movies option.
-The plugin loads the json file, filters the huge json, returns only the group of movies and prints the filters menu (Director, Gender, Year).
-I choose the Year option.
-The plugin loads the json file, filters the huge json, returns only the group of movies, filters the group of movies by year, returns a group for each year found and prints the menu with each year.
-I select 2018.
-The plugin loads the json file, filters the huge json, returns only the group of movies, filters the group of movies by year, returns a group for each year found, filters the group of movies for the year 2018 and prints their titles.


My question is, how can I make the data generated by the intermediate steps persistent, in order to avoid all this calls to the same functions?
Reply



Logout Mark Read Team Forum Stats Members Help
Passing data around a multi folder menu?0
This forum uses Lukasz Tkacz MyBB addons.