Help with Search dialog box
#1
I would like to implement a search feature in my addon and would like to know if anyone has an example to open the search dialog and then return a string that i can use

ie

open dialog:
searchtext = getkeyboadtext

url = 'http://www.xxxx.com/search' + url

thks
Reply
#2
Code:
searchStr = ''
        keyboard = xbmc.Keyboard(searchStr,'Search')
        keyboard.doModal()
        if (keyboard.isConfirmed() == False):
            return
        searchStr = keyboard.getText()   #.replace(' ','+')  # sometimes you need to replace spaces with + or %20
        if len(searchStr) == 0:
            return
        else:
            return searchStr
Reply
#3
divingmule Wrote:
Code:
searchStr = ''
        keyboard = xbmc.Keyboard(searchStr,'Search')
        keyboard.doModal()
        if (keyboard.isConfirmed() == False):
            return
        searchStr = keyboard.getText()   #.replace(' ','+')  # sometimes you need to replace spaces with + or %20
        if len(searchStr) == 0:
            return
        else:
            return searchStr

Thanks Divingmule, worked fine once i figured i had to use it in a function due to the returns

Also if a user cancels, how do you make it so the page does not continue on to the next page and then shows 2 little dots (back dir) at top of page.

thanks
Reply
#4
Good question, I don't know.Smile Anyone else ?
Reply
#5
I managed to find out why after selecting ok on a dialog box why it continued to the next page anyway.

By default addon.end_of_directory() is called
ie.
if not play:
addon.end_of_directory()

so i comment out these 2 lines and add addon.end_of_directory() wherever in my code that i do want to goto a new page. usually after i have finished loading menus. That way when i click ok the end of directory does not get called.

Code:
elif mode == 'GetMovieSource':

        html = net.http_GET(url).content
        match=re.compile('<li class="searchList"><a href="#/mirror/(.+?)" onclick="switchMirror.+?">(.+?)</a>').findall(html)
        x = 0
        st = 0
        streamfound=''
        if match:

            for url,name in match:

                if ValidLinks(name) == 'yes':
                    x = x + 1
                    addon.add_video_item({'url':'http://tvsearch.co/i/application/ajax.php?op=switchMirror&vid=' + url} ,{'title': name})
                    #addon.add_directory({'mode' : 'GetLink', 'url' : 'http://tvsearch.co/i/application/ajax.php?op=switchMirror&vid=' + url , 'img' : '' }, name, '')

                else:
                    st = 1
                    if streamfound == '':
                        streamfound = name
                    else:
                        streamfound = streamfound + ',' + name

            if x == 0 and st == 1:
                dialog = xbmcgui.Dialog()
                dialog.ok('Streams Found', streamfound + ' Stream Found But Not Implemented')
            else:
                addon.end_of_directory()   <<<< HERE
        else:
                dialog = xbmcgui.Dialog()
                dialog.ok('No Streams', 'No Playable Streams Found')
Reply

Logout Mark Read Team Forum Stats Members Help
Help with Search dialog box0