python question - xbmcgui.ListItem
#1
I try to set some items to KODI but it did not work for me...

Code:
addon_handle = int(sys.argv[1])

elif methode == 'get_item_serienplaner':
    sp_items = refreshWidget(__LS__(30116))
    writeLog('spitems %s' % (sp_items), level=xbmc.LOGDEBUG)
    url = '-'
    for sitem in sp_items:

        li = xbmcgui.ListItem(sitem['TVShow'], thumbnailImage=sitem['Thumb'])
        li.setProperty("channel", sitem['Channel'])
        li.setArt("Poster"), sitem['Poster']
        li.setProperty("plot", sitem['Description'])
        li.setProperty("staffel", sitem['Staffel'])
        li.setProperty("episode", sitem['Episode'])
        li.setProperty("starttime", sitem['Starttime'])
        li.setProperty("rating", sitem['Rating'])
        li.setProperty("senderlogo", sitem['Logo'])
        li.setProperty("genre", sitem['Genre'])
        li.setProperty("date", sitem['Datum'])
        li.setProperty("rumtime", sitem['RunningTime'])
        li.setProperty("studio", sitem['Studio'])
        li.setProperty("year", sitem['Jahr'])
        li.setProperty("altersfreigabe", sitem['Altersfreigabe'])
        li.setProperty("status", sitem['Status'])
        li.setProperty("label", sitem['Title'])
        li.setProperty("label2", sitem['TVShow'])
        xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
    xbmcplugin.endOfDirectory(addon_handle)

sp_items looks like this:

Code:
spitems [{'neueEpisode': u'', 'Thumb': u'http://www.thetvdb.com/banners/episodes/85228/4126685.jpg', 'Title': u'Schutzlos', 'Jahr': u'2009', 'Staffel': u'5', 'TVShow': u'Law & Order: UK', 'Channel': u'13th Street HD', 'Status': u'Continuing', 'Description': u'Ein zweij\xe4hriger Junge wird vermisst. Zun\xe4chst deutet alles darauf hin, dass sein getrennt von ihm lebender Vater Jimmy etwas damit zu tun haben k\xf6nnte. Doch dann verwickelt sich die Mutter Kayla in mehrere Widerspr\xfcche.', 'Poster': u'http://thetvdb.com/banners/posters/85228-4.jpg', 'FirstAired': u'2011-07-17', 'Studio': u'ITV1', 'Genre': u'Crime | Drama', 'Episode': u'2', 'Starttime': u'15:45', 'Altersfreigabe': u'', 'Rating': u'7.8', 'WatchType': u'Internationale Serien', 'Datum': u'13.04.2016', 'RunningTime': u'55', 'Logo': u'image://G%3a%5cKodi%5cSenderlogos%5c13th%20street%20hd.png/', 'PVRID': u'56'}, {'neueEpisode': u'', 'Thumb': u'http://www.thetvdb.com/banners/episodes/266609/4494888.jpg', 'Title': u'Das Fremde unter der eigenen Haut', 'Jahr': u'2013', 'Staffel': u'1', 'TVShow': u'Rectify', 'Channel': u'Sky Atlantic HD', 'Status': u'Continuing', 'Description': u'Daniel hat M\xfche sich an das Leben in Freiheit zu gew\xf6hnen und beginnt seine fremd gewordene Heimatstadt zu erkunden. Doch Amantha sorgt sich um seine Sicherheit. Ted Jr. k\xfcmmert dagegen mehr, wie sich das Familienunternehmen entwickeln wird. Auf Daniels Willkommensparty kommt es zu weiteren Spannungen. Senator Foulkes erh\xe4lt unterdessen von seiner Ex-Geliebten wertvolle Informationen.', 'Poster': u'http://thetvdb.com/banners/posters/266609-5.jpg', 'FirstAired': u'2013-04-22', 'Studio': u'SundanceTV', 'Genre': u'Drama', 'Episode': u'2', 'Starttime': u'15:50', 'Altersfreigabe': u'TV-14', 'Rating': u'7.5', 'WatchType': u'Internationale Serien', 'Datum': u'13.04.2016', 'RunningTime': u'70', 'Logo': u'image://G%3a%5cKodi%5cSenderlogos%5csky%20atlantic%20hd.png/', 'PVRID': u'50'}, {'neueEpisode': u'', 'Thumb': u'http://www.thetvdb.com/banners/episodes/70851/372020.jpg', 'Title': u'Inquisition', 'Jahr': u'2004', 'Staffel': u'5', 'TVShow': u'Stargate: Atlantis', 'Channel': u'Syfy HD', 'Status': u'Ended', 'Description': u'Colonel Sheppards Team wird zu einem Treffen verschiedener menschlicher V\xf6lker der Pegasus Galaxie eingeladen. Doch sofort nach ihrer Ankunft werden alle gefangen genommen. Die neu gegr\xfcndete Koalition der Menschenv\xf6lker will Colonel Sheppard vor Gericht stellen und f\xfcr die Taten von Atlantis zur Rechenschaft ziehen. Sie sollen direkt oder indirekt f\xfcr den Tod von zwei Millionen Menschen verantwortlich sein. Wenn der aus drei Mitgliedern bestehende Rat ihn f\xfcr schuldig befindet, werden Sheppard und sein Team f\xfcr Lebzeiten auf einen einsamen Planeten verbannt. Sheppard rechtfertigt sich so gut es geht daf\xfcr, dass sein Team damals die Wraith fr\xfchzeitig geweckt und sp\xe4ter das Halbblut Michael erschaffen hat. Woolsey ist emp\xf6rt, dass seine Leute entf\xfchrt wurden und bietet sich als ihr Verteidiger bei der Gerichtsverhandlung an. Offenbar war er fr\xfcher als Anwalt t\xe4tig und kennt alle Tricks. Irgendwann kommt er dahinter, dass das Ratsmitglied Kelore mit den Genii unter einer Decke stecken muss und der Prozess ein abgekartetes Spiel ist. Ausgerechnet der sonst so prinzipientreue Woolsey besticht Kelore und gewinnt so den Prozess. Nat\xfcrlich macht er sich sofort darauf Sorgen, wie er das dem Komitee erkl\xe4ren soll...', 'Poster': u'http://thetvdb.com/banners/posters/70851-6.jpg', 'FirstAired': u'2008-10-24', 'Studio': u'Syfy', 'Genre': u'Action | Adventure | Science-Fiction', 'Episode': u'13', 'Starttime': u'15:50', 'Altersfreigabe': u'TV-PG', 'Rating': u'6.9', 'WatchType': u'Klassiker', 'Datum': u'13.04.2016', 'RunningTime': u'50', 'Logo': u'image://G%3a%5cKodi%5cSenderlogos%5csyfy%20hd.png/', 'PVRID': u'48'}]

so I don't know what I'm doing wrong...

I get the following error:
Code:
Error Type: <type 'exceptions.TypeError'>
Error Contents: an integer is required
Traceback (most recent call last):
File "G:\Kodi\portable_data\addons\plugin.program.serienplaner\default.py", line 663, in <module>
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li)
TypeError: an integer is required

I also tried
Code:
addon_handle = str(sys.argv[1])
Board: B85M-ITX
CPU: i3 4330
GPU: Geforce GTX 750ti
Reply
#2
Is this in a plugin?

The str() conversion shouldn't work.

Also for when you find the error. If you have many listitems look into adding all at onve with addDirectoryItems.
Reply
#3
it is a script... but I got work now...
So I get all ListItems in the container, but now I have other problem...
I refresh the container content every 5min in the script but don't get the content updatet in the skin...

I call the container as follow:

Code:
<content>plugin://plugin.program.serienplaner/?methode=get_item_serienplaner</content>
Board: B85M-ITX
CPU: i3 4330
GPU: Geforce GTX 750ti
Reply
#4
Yes. Kodi caches the result from the url. What i did when i used plugins. Was to add a trigger value to the url. Like ?randomnumber=1275. Basically anything that changes the url.

Or go the long route and drop the content tag and simply fill the list using the id if you can.

How did ypu solbe the problem?
Reply
#5
(2016-04-15, 21:52)Torben Wrote: Yes. Kodi caches the result from the url. What i did when i used plugins. Was to add a trigger value to the url. Like ?randomnumber=1275. Basically anything that changes the url.

could you explain me a litle bit more.. I'm very new to this and do really understand what you mean

Quote:Or go the long route and drop the content tag and simply fill the list using the id if you can.

you mean the sys.argv[1] could be possible i think cause I debug them

Code:
SerienPlaner sysargv: ['plugin://plugin.program.serienplaner/', '9', '?methode=get_item_serienplaner]

Quote:How did ypu solbe the problem?

oh it was quit simple....
I called it in a wrong way... cause it is a script I tried ``RunScrpit(.....)``
but I only has to call it like a plugin... ``plugin://plugin.program.serienplaner/?methode=get_item_serienplaner``

after that it works beside that I can't update it....
Board: B85M-ITX
CPU: i3 4330
GPU: Geforce GTX 750ti
Reply
#6
The container is only re-filled if the url changes. If you have a script running in Kodi anyways you can use that to update a parameter each five minutes. And use that param in the url. That will change the url. Sorry.. kids... later
Reply
#7
The sysarfv 1 is just an increasing whole number. I have no idea what it is good for. It is the connection back to the kodi list - if you use a plugin.

You can fill the list from a scriot if you desire. You dont have to use the plugin structure at all. It us just an option. But probably a nice one...
Reply
#8
Hi Torben,

thanks for your help.
(2016-04-16, 08:07)Torben Wrote: You can fill the list from a scriot if you desire. You dont have to use the plugin structure at all. It us just an option. But probably a nice one...

do you have an example for this that sounds interesting...

(2016-04-16, 07:45)Torben Wrote: The container is only re-filled if the url changes. If you have a script running in Kodi anyways you can use that to update a parameter each five minutes. And use that param in the url. That will change the url.

so Iwould need one parameter at the end of the url like

Code:
plugin://plugin.program.serienplaner/?methode=get_item_serienplaner&amp;refresh=$INFO[Window(Home).Property(contentrefresh)]

and content refresh will be set in the every 5min new?
[code]WINDOW.setProperty('SerienPlaner.%s % (contentrefresh))

and
Board: B85M-ITX
CPU: i3 4330
GPU: Geforce GTX 750ti
Reply
#9
Yes. Everytime the " contentrefresh" changes the url fires :-)
Reply
#10
See rhe code here for hiw ro fill a list directly
http://forum.kodi.tv/showthread.php?tid=268181

Actually ir is not rhe complwrw xode. Look up setStaticContent
Reply
#11
would it be possible to use a timestamp for this?
that would be the easies way... everytime the widget refresh within the script this property will set to the current time...
Board: B85M-ITX
CPU: i3 4330
GPU: Geforce GTX 750ti
Reply
#12
Sounds perfect :-) perhaps use the epochseconds only to avoid any odd regional chars ending up in the url.
Reply
#13
@Torben:
thanks for that... works perfect....
Board: B85M-ITX
CPU: i3 4330
GPU: Geforce GTX 750ti
Reply

Logout Mark Read Team Forum Stats Members Help
python question - xbmcgui.ListItem0