Making listitem call method in same file
#1
Hi,

I am making a simple addon for moving folders via FTP.

What I am doing now, is listing all the folders in the working dir, by adding listitems with xbmcplugin.addDirectoryItem(...)

What I want to do is show a select dialog every time one of these folders are pressed, so that I can choose an option with where to move the folder (I have some predetermined destinations).

The only way I can achieve this right now, is by adding a parameter to the listitem url, but this can be very slow, as I am doing all the same and unnecessary code again each time the dialog is opened.

Is there a way to carry out some code in the same .py file, instead of basically call itself with a parameter?


Thanks in advance,

- Mikael
Reply
#2
This is basically what I've got atm:
Code:
#...
#imports and variable declarations...
#...
PATH = sys.argv[0]
HANDLE = int(sys.argv[1])
PARAMS = urlparse.parse_qs(sys.argv[2][1:])

if "index" in PARAMS:
    ret = xbmcgui.Dialog().select("Choose destination", destinations)

    if ret != -1:
        #do move stuff...
else:
    ftp.login()
    folders = ftp.listContent()

    for i in range(0, len(downloads)):
        listitem = xbmcgui.ListItem(folders[i])
        xbmcplugin.addDirectoryItem(HANDLE, PATH + "?index=%d" % i, listitem, isFolder=True)

    xbmcplugin.endOfDirectory(HANDLE)
    ftp.logout()
Reply

Logout Mark Read Team Forum Stats Members Help
Making listitem call method in same file0