2017-12-06, 22:15
I'm trying to reuse a variable I created in the main folder when accessing one of the subfolders. Is this possible? And how would I go about it?
The variable 'pages' does an API call, and I need it to build the main menu. However, I want to limit the number of API calls I make.
So in the submenu, I would like to reuse the information in the 'pages' variable, instead of making the same API call (because the API call is slow, and of course rate limiting might be an issue). Is there a way to retain a variable? Or should I use a different approach? Can I create the entire menu (all main folders and subfolders) all at once in the main menu (I'm pretty sure I can't but I want to be sure)? I'm still new to addon development, so there is a fair chance I'm doing it completely wrong. Please be patient with me.
PS sorry for the formatting, I have no idea why the spacing is so huge in the code here on the forum
The variable 'pages' does an API call, and I need it to build the main menu. However, I want to limit the number of API calls I make.
So in the submenu, I would like to reuse the information in the 'pages' variable, instead of making the same API call (because the API call is slow, and of course rate limiting might be an issue). Is there a way to retain a variable? Or should I use a different approach? Can I create the entire menu (all main folders and subfolders) all at once in the main menu (I'm pretty sure I can't but I want to be sure)? I'm still new to addon development, so there is a fair chance I'm doing it completely wrong. Please be patient with me.
python:if mode is None:
pages = get_videos()
items = unique_items(pages)
for item in items:
url = build_url({'mode':'item', 'foldername':item.replace('_',' ')})
li = xbmcgui.ListItem(item.replace('_',' '))
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url,
listitem=li, isFolder=True)
xbmcplugin.endOfDirectory(addon_handle)
elif mode[0] == 'item':
events = get_items(pages, mode[0])
years = unique_years(events)
for year in years:
url = build_url({'mode':year, 'foldername':year})
li = xbmcgui.ListItem(year)
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url,
listitem=li, isFolder=True)
xbmcplugin.endOfDirectory(addon_handle)
PS sorry for the formatting, I have no idea why the spacing is so huge in the code here on the forum