Make listitem a folder after it's been created
#1
Hi!

If I create a directory item using "addDirectoryItem(handle, url, listitem, isFolder=False)", is it possible to afterwards make it become a folder (i. e. set isFolder to True)?

I have an addon which lists movies and tv shows in the same directory. So I want to have the directory contain both links and folders. The problem is that there's no way to know beforehand if the item is a show or a movie - so in the creation all items will be set as links. Therefore, when clicking an item, if it turns out to be a tv show, I would like to be able to set it as a folder in order to create a new directory with the episodes.

The question is, is it possible?

Thanks! Smile
Reply
#2
Pass it as an argument...

Code:
def addDir(name,url,mode,iconimage,folder=False):
    u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)
    ok=True
    liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
    ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=pasta,totalItems=total)
    return ok

addDir('item 1','your_url',your_mode,False) -> not a directory
addDir('item 2','your_url',your_mode,True) -> a directory
Reply
#3
No, once it has been added it cannot be changed.
Reply
#4
enen92:
Thank you but the problem is that I want to alter the item after it has been created (since I have no way of knowing if it is to be a folder or link in the creation process.

ironic_monkey:
Ok, thanks for the answer!
Reply
#5
Yap once added you can't change it. Your question is a bit confusing.

The same way you parse the url, name and mode you can add another one for a parameter that will be true if the content is a movie and false if it isn't.
Reply
#6
Yes, sorry! I might have been a bit unclear. I am aware that you can mix folders and links by setting the isFolder-parameter to either True or False in the creation process. This does, however, not solve my problem as I still don't know whether the item should be a folder or not until it's been created. The reason is this: on the website I'm scraping, you must click on a link in order to see if it's a movie or tv show. Since I don't want to open all the links on the page at once I have no other alternative then to make a function that detemines whether or not the item is a movie once it's clicked.

But it's been made clear that it's impossible to make an item a folder after it's been created I use a select dialog to display the episodes (if it's a tv show) instead.

I hope I was able to better explain my situation Smile
Reply
#7
I see, hope this is not some ilegal addon that do not comply with the forum rules..

A simple (but uggly) way of overcoming this problem is to set always isFolder as True and, in case you don't want it to be a folder, call sys.exit(0) at the end of the next function (the one called on the mode you define next).
It works but, it's uggly and hackish.
Reply
#8
Ah, no, it's a legal swedish site I'm scraping so I can't imagine it would be against the forum rules...

I will certainly try this out and see how it works. I don't mind if it's ugly; all my scripting is!

Thanks!
Reply

Logout Mark Read Team Forum Stats Members Help
Make listitem a folder after it's been created0