--- misc/xbmc/plugin.video.todic/default.py 2011/11/27 11:01:27 1629 +++ misc/xbmc/plugin.video.todic/default.py 2011/11/28 19:02:04 1640 @@ -27,10 +27,16 @@ def rootMenu(): link = open_url(__backend__) m=re.compile('(.+?)(.+?)').findall(link) + l = len(m) for name,url in m: listitem = xbmcgui.ListItem(label = name, iconImage = 'DefaultFolder.png', thumbnailImage = 'DefaultFolder.png') u = sys.argv[0] + "?mode=1&name=" + urllib.quote_plus(name) + "&url=" + urllib.quote_plus(url) - ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True) + ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True, totalItems = l) + + listitem = xbmcgui.ListItem(label = "Søg film ...", iconImage = 'DefaultFolder.png', thumbnailImage = 'DefaultFolder.png') + u = sys.argv[0] + "?mode=10&name=" + urllib.quote_plus(name) + ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = True, totalItems = l) + xbmcplugin.endOfDirectory(int(sys.argv[1])) @@ -40,6 +46,7 @@ ty=re.compile('(.+?)(.+?)(.+?)').findall(link) + l=len(m) for name,url,thumb in m: if ty[0] == 'clipList': mode = '50' @@ -50,17 +57,18 @@ listitem = xbmcgui.ListItem(label = name, iconImage = 'DefaultFolder.png', thumbnailImage = thumb) u = sys.argv[0] + "?mode=" + urllib.quote_plus(mode) + "&name=" + urllib.quote_plus(name) + "&url=" + urllib.quote_plus(url) - ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = folder) + ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = folder, totalItems = l) xbmcplugin.endOfDirectory(int(sys.argv[1])) def buildSubList(url,title): print '[TODIC]:'+str(url) link = open_url(url) m=re.compile('(.+?)(.+?)(.+?)').findall(link) + l = len(m) for name,url,thumb in m: listitem = xbmcgui.ListItem(label = name, iconImage = 'DefaultFolder.png', thumbnailImage = thumb) u = sys.argv[0] + "?mode=50&name=" + urllib.quote_plus(name) + "&url=" + urllib.quote_plus(url) - ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = False) + ok = xbmcplugin.addDirectoryItem(handle = int(sys.argv[1]), url = u, listitem = listitem, isFolder = False, totalItems = l) xbmcplugin.endOfDirectory(int(sys.argv[1])) @@ -77,6 +85,45 @@ xbmc.Player(xbmc.PLAYER_CORE_AUTO).play(str(url), listitem) xbmc.sleep(200) +def search(): + search = getUserInput("Todic Søgning") + + if (search != None and search != ""): + url = __backend__ + "&action=search&search=" + urllib.quote_plus(search) + + #print "[TODIC] Search start: " + search + #print "[TODIC] Search url: " + url + + buildSubList(url, "søgning") + + + + + +#=================================== Tool Box ======================================= +# shows a more userfriendly notification +def showMessage(heading, message): + duration = 15*1000 + xbmc.executebuiltin('XBMC.Notification("%s", "%s", %s)' % ( heading, message, duration) ) + + +# raise a keyboard for user input +def getUserInput(title = "Input", default="", hidden=False): + result = None + + # Fix for when this functions is called with default=None + if not default: + default = "" + + keyboard = xbmc.Keyboard(default, title) + keyboard.setHiddenInput(hidden) + keyboard.doModal() + + if keyboard.isConfirmed(): + result = keyboard.getText() + + return result + def get_params(): param=[] @@ -131,10 +178,14 @@ #build list of series buildSubList(url, name) +elif mode == 10: + search() + + elif mode == 50: play_video(url, name) -xbmcplugin.endOfDirectory(int(sys.argv[1])) +# xbmcplugin.endOfDirectory(int(sys.argv[1]))