Kodi Community Forum
ListItem displays plugin name as label, ignores setLabel - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: ListItem displays plugin name as label, ignores setLabel (/showthread.php?tid=54280)



ListItem displays plugin name as label, ignores setLabel - chuckles - 2009-07-09

I'm trying to create a list in my test plugin and I cant get listItem to display the desired label. It displays the name of the plugin as my label for all my items, even when I use static label text

My code is as below

Code:
li=xbmcgui.ListItem( label='Test')
li.setInfo( type="Video", infoLabels={ "Title": name } )
u=sys.argv[0]+"?mode=3&name="+urllib.quote_plus(name)+"&url="+urllib.quote_plus(URLS[x])
ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=li, isFolder=False)

Instead of displaying "Test" for listItem label it displays the name of my plugin

Anybody got an idea why?


- jmarshall - 2009-07-09

Which version of XBMC, as this was fixed a while back, but it keeps popping up (i.e. there's something you're doing differently than other plugins).

If it's a recent SVN build, then I'll need a trac ticket (there probably already is one - have a search and let me know if there is) with an example plugin attached.

Cheers,
Jonathan


- chuckles - 2009-07-12

jmarshall Wrote:Which version of XBMC, as this was fixed a while back, but it keeps popping up (i.e. there's something you're doing differently than other plugins).

If it's a recent SVN build, then I'll need a trac ticket (there probably already is one - have a search and let me know if there is) with an example plugin attached.

Cheers,
Jonathan

Apologies for the late reply

I was using Windows Rev21496
I went back and tested on Babylon Beta1 and 9.04.1(repack2)

All have the same result

I couldn't find a trac ticket. I'll see if I can get the script down to its barebones and open a new ticket


- chuckles - 2009-07-12

I have created a Ticket #6898. Here is the code here as well

Code:
#PLUGIN NAME: KidsTube
#VERSION: 0.01
#DATE: 5 July 2009
#AUTHOR: Chuckles


import xbmc, xbmcgui, xbmcplugin, urllib2, urllib, re, string

def showList(url,page):
        thisurl=url
        f=urllib2.urlopen(url)
        a=f.read()
        f.close()
        p=re.compile('<li><a href="(.+?)"><img src="(.+?)" alt="video pic" border="0" class="IndexVideoDetails_Thumb" />')
        o=re.compile('<span class="font4_14-1">(.+?)</span>')
        match=p.findall(a)
        NAMES=o.findall(a)
        x=0
        for rel_url, name in match:
          li=xbmcgui.ListItem("Test")
          #li=xbmcgui.ListItem(NAMES[x])
          li.setInfo( type="Video", infoLabels={ "Title": NAMES[x] } )
          u=sys.argv[0]+"?mode=3&name="+urllib.quote_plus(NAMES[x])+"&url="+urllib.quote_plus(rel_url)
          ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=li)
          x=x+1

url=urllib.unquote_plus("http://www.kidstube.com/")
page=1

showList(url,page)

xbmcplugin.endOfDirectory(int(sys.argv[1]))



- stacked - 2009-07-12

Code:
#PLUGIN NAME: KidsTube
#VERSION: 0.01
#DATE: 5 July 2009
#AUTHOR: Chuckles


import xbmc, xbmcgui, xbmcplugin, urllib2, urllib, re, string

def showList(url,page):
        thisurl=url
        f=urllib2.urlopen(url)
        a=f.read()
        f.close()
        p=re.compile('<li><a href="(.+?)"><img src="(.+?)" alt="video pic" border="0" class="IndexVideoDetails_Thumb" />')
        o=re.compile('<span class="font4_14-1">(.+?)</span>')
        match=p.findall(a)
        NAMES=o.findall(a)
        x=0
        for rel_url, name in match:
          li=xbmcgui.ListItem("Test")
          #li=xbmcgui.ListItem(NAMES[x])
          li.setInfo( type="Video", infoLabels={ "Title": NAMES[x] } )
          u=sys.argv[0]+"?mode=3&name="+urllib.quote_plus(NAMES[x])+"&url="+urllib.quote_plus(rel_url)
          ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=li)
          x=x+1

url=urllib.unquote_plus("http://www.kidstube.com/")
page=1

showList(url,page)

[b]xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_LABEL )[/b]
xbmcplugin.endOfDirectory(int(sys.argv[1]))

You need to add a sortmethod. I added to your code above...


- jmarshall - 2009-07-12

So with the sort method added you don't get the problem?

Cheers,
Jonathan


- stacked - 2009-07-12

jmarshall Wrote:So with the sort method added you don't get the problem?

Cheers,
Jonathan

I'm not sure if it works with all methods, but SORT_METHOD_LABEL seems to fix the problem.


edit...I also tried SORT_METHOD_DATE and that works too. So I guess any sort method would fix the problem.


- jmarshall - 2009-07-12

Interesting. Will see if I can figure out why this is necessary.


- chuckles - 2009-07-12

stacked Wrote:You need to add a sortmethod. I added to your code above...


I can confirm that this works. Thanks!!!


- mkortstiege - 2009-07-12

FYI, r21647 will return a proper listing if there's no sortmethod set.