Plugin File actions
#1
Hey guys,

I'm playing about to make myself a plugin. I'm new to it, but have been managing quite well with Voinages plugin tutorials in the wiki. The problem is, I've gone past some of that, and I'm actually really stuck for it.

The problem is I don't want to play a video or anything, I want to write to a file instead.

Code:
def addLink(name,url,iconimage):
        ok=True
        liz=xbmcgui.ListItem(name, iconImage="DefaultProgram.png", thumbnailImage=iconimage)
        liz.setInfo( type="Video", infoLabels={ "Title": name } )
        ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url="C:\\",listitem=liz)
        return ok
This is what I'm using, and the problem seems to be after this step. I'm able to list the directory well enough (Using the C path atm because otherwise XBMC was just restarting), but I don't know how to do the actual action. What i want is so that when i click on one of those links, it will call a function "WRITE()" which just writes the name to a text file.

I tried adding a mode switch into the addLink to use the elif at the bottom, but that method doesn't seem to actually call. can anyone help me with any suggestions?

Sorry if this is too vague, I've been trying all night (pathetic I know) and need sleep. I'll try to explain better later if it doesn't make any sense.

thanks
Reply
#2
Code:
#fin de liste
def end_of_directory( OK ):
    xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=OK )


#Menu principal
if mode==None:
    listing()
    end_of_directory( True )
    
#Menu série tv
elif mode==1:
    current_show = Tvshow(url)
    current_show.get_xml()
    parser(current_show)
    if current_show.clearart != "no clearart": addDir('Clearart',url,2,'')
    if current_show.season: addDir('Seasonthumbs',url,2,'')
    if current_show.tvshowthumb != "no tvthumb": addDir('TVthumbs',url,2,'')
    if current_show.collection:
        for i in current_show.collection: addDir("Collection: %s" % (i),url,2,'')
    end_of_directory( True )


#Menu images
elif mode==2:
    current_show = Tvshow(url)
    parser(current_show)
    current_show.menu_list(name)
    end_of_directory( True )
    
#mode de téléchargement des images
elif mode==3:
    #tri car les saisons arrive avec des parametres différents
    if name[:6] == "season":
        type = name
        id = url.rsplit("&&")[1]
        url= url.rsplit("&&")[0]
    else:
        type=url.rsplit("&&")[0]
        id=url.rsplit("&&")[1]
        url=name
        
    print "--type: %s"%(type)
    print "--id: %s"%(id)
    print "--url: %s"%(url)
    current_show = Tvshow(id)
    print "tvshowpath= %s" % (current_show.path)
    
    end_of_directory( False )
    
    from mydialog import MyDialog
    MyDialog( type, url, type=type )
    
#mode de téléchargement de collection
elif mode==4:
    type=name[13:]
    id=url.rsplit("&&")[1]
    name=url.rsplit("&&")[0]
    print "--type: %s"%(type)
    print "--id: %s"%(id)
    print "--collection name: %s"%(name)
    
    
    if xbmcgui.Dialog().yesno( "collection download" , "Do you want to download this collection?" ):
        current_show = Tvshow(id)
        parser(current_show)
        current_show.dl_collection(type,id,name)

    else:
        end_of_directory( False )

I set end_of_directory( False ) to stop the plugin to go deeper in virtual directory, so it stay on same page but you can add action before.
(part of code from xbmcstuff downloader plugin)
Reply
#3
Hey ppic, thanks for replying. I didn't get that to work immediately, but it did help me to improve and fix the problem. It does go into the non-directory with me, but I guess it doesnt really matter since it's meant to autolaunch a program anyway.

Cheers
Reply
#4
just watch the default.py in xbmcstuff downloader, you should be able to find how it works.
Reply

Logout Mark Read Team Forum Stats Members Help
Plugin File actions0