2018-09-29, 13:26
Hi,
So I have my script running fine and all, but one problem that is annoying the heck out of me and honestly can't figure it out. When I activate the window for my addon, then each time I prev back, it will just refresh the page unless I press back quick enough 2 times. I can see in the args that pressing back has the exact same list as the initial list of arguments meaning that it's always going to filter through the same method. Here is my code:
I also call this addon from JSONRPC via the activate window command
an example of the args being passed in are:
Can someone please help me rectify this?
So I have my script running fine and all, but one problem that is annoying the heck out of me and honestly can't figure it out. When I activate the window for my addon, then each time I prev back, it will just refresh the page unless I press back quick enough 2 times. I can see in the args that pressing back has the exact same list as the initial list of arguments meaning that it's always going to filter through the same method. Here is my code:
python:
import os
import sys
import urlparse
import urllib
import xbmcgui
import xbmcplugin
import xbmcaddon
import xbmc
import json
ADDON = xbmcaddon.Addon()
CWD = ADDON.getAddonInfo('path').decode('utf-8')
# Add our resources/lib to the python path
try:
current_dir = os.path.dirname(os.path.abspath(__file__))
except:
current_dir = os.getcwd()
sys.path.append(os.path.join(current_dir, "resources", "lib"))
import libraryitems, log, jsonquery
base_url = sys.argv[0]
addon_handle = int(sys.argv[1])
args = urlparse.parse_qs(sys.argv[2][1:])
if args.get('title', None):
title = args.get('title')[0]
else:
title = "Filter"
handler = os.path.basename(sys.argv[0])
xbmc.executebuiltin("Dialog.Close(busydialog)")
if __name__ == "__main__":
if handler is None:
xbmc.executebuiltin('ActivateWindow(Home)')
elif handler == 'movies':
filters = urllib.unquote( args.get('filter', None)[0] ).decode('utf8')
filters = json.loads(filters)
movies = jsonquery.getMovies(filters)
xbmcplugin.setContent(addon_handle, 'movies')
listitems =
for index, movie in enumerate(movies):
listitem = libraryitems.movieItem(movie)
xbmcplugin.addDirectoryItems(addon_handle, [(movie['file'], listitem, False,)])
xbmc.executebuiltin('Container.SetViewMode(53)')
xbmcplugin.endOfDirectory(addon_handle, succeeded=True, updateListing=False, cacheToDisc=False)
I also call this addon from JSONRPC via the activate window command
an example of the args being passed in are:
json:
[
"plugin://script.module.customlibrarywindow/movies",
"65",
"?handler=movies&filter=%257B%2522or%2522%253A%255B%257B%2522field%2522%253A%2522rating%2522%252C%2522value%2522%253A%25228%2522%252C%2522operator%2522%253A%2522greaterthan%2522%257D%255D%257D&title=Movies+greaterthan+8"
]
Can someone please help me rectify this?