Kodi Community Forum
ListItem fromString and offscreen=True - 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 fromString and offscreen=True (/showthread.php?tid=307394)

Pages: 1 2 3


ListItem fromString and offscreen=True - null_pointer - 2017-02-18

I have been revisiting an old addon I was working on and had some issues with ListItems being slow to create on slow machines like Pi2 etc
The problem was as soon as I called any of the setProp or setInfo function on the ListItems it was very slow, about 10 times slower than not setting any info.
My theory on this is variable marshaling between the Python and C++ interface but I am not sure.

Anyway I was then looking though the latest Kodi 17 python doscs and noticed this
https://codedocs.xyz/AlwinEsch/kodi/group__python__xbmcgui__listitem.html#ga3dcc3339497986459166c03e6a097bd6

does this mean I can create a ListItem object from a string? If so how? Is there any docs on using this? As you can see from the above there are no examples and I can not find anything that shows how to use this.


RE: ListItem::fromString - null_pointer - 2017-02-18

Also how can I create a ListItem in offscreen=True mode

I tryed the following:

list = xbmcgui.ListItem(listItemName, iconImage=thumbPath, thumbnailImage=thumbPath, offscreen=True)

But I get this error

TypeError: 'offscreen' is an invalid keyword argument for this function


RE: ListItem fromString and offscreen=True - null_pointer - 2017-02-18

I think I can answer my own question here, offscreen is not available yet available.

It was added in the following commit:
https://github.com/xbmc/xbmc/commit/7c994ce9ef3822a2cc27ae59f42eb7b5fba052f7

This is in main, does this mean it is available in Leia?


RE: ListItem fromString and offscreen=True - ronie - 2017-02-18

the slow creation of listitems is fixed in master (Leia):
https://github.com/xbmc/xbmc/pull/11651

and will be fixed in the upcoming 17.1 release as well:
https://github.com/xbmc/xbmc/pull/11660


the 'offscreen' arg is only available in master indeed, it was added specifically for python based scrapers,
i'm not sure if it can/should be used by other types of addons as well.

there's no documentation for the fromString() method. i believe is should be used like this:
Code:
listitem = xbmcgui.ListItem().fromString('Hello World')



RE: ListItem fromString and offscreen=True - null_pointer - 2017-02-18

thank for confirming that.

You mentioned Python based scrappers.
The addon I am working on goes out to a media server and gets a list of movies from a web api and then builds ListItems to show these movies in Kodi. Would this be considered a scrapper?


RE: ListItem fromString and offscreen=True - ronie - 2017-02-18

nope, i was referring to our metadata scrapers... the one you use when you scan your media to the library.


RE: ListItem fromString and offscreen=True - null_pointer - 2017-02-19

I just had a play with OSMC Kodi 18 and the offscreen=True option, when creating ListItem objects this significantly speeds up creating many items 200+ for display.

Initial tests went from 15 seconds to load and create 450 items down to about 2 seconds on my test RPi2 with just one line change.


RE: ListItem fromString and offscreen=True - ronie - 2017-02-19

as you can read in the commit you linked to, offscreen should only be set to True for listitems that are not going to be displayed ;-)


RE: ListItem fromString and offscreen=True - null_pointer - 2017-02-19

not on the screen now or never going to be on the screen?
From what I can see in the source if you are building this item to be eventually shown on the screen that should be ok.


RE: ListItem fromString and offscreen=True - ronie - 2017-02-19

never ever Smile


RE: ListItem fromString and offscreen=True - null_pointer - 2017-02-20

why is this?
If the ListItem is not on the screen currently why does it need a GUI lock when you set data in it?


RE: ListItem fromString and offscreen=True - ronie - 2017-02-20

if i could give an accurate answer i would :-)

perhaps someone with a better understanding of GUI locking can chime in?


RE: ListItem fromString and offscreen=True - null_pointer - 2017-02-20

I would like to go deeper on this and find out if this is a valid use of the offscreen param.
If I can create a bunch of ListItems offscreen and then return them in the addon it can speed it up by a factor of 10.
If this is not valid and might stop working in a future update then I wont bother.

Anyone care to comment?


RE: ListItem fromString and offscreen=True - ironic_monkey - 2017-02-20

That is the intended use. The gui is uselessly locked in most cases. as long as the item do not sit in a onscreen container this should be set. I just couldnt change the default as that would break legacy code depending on it.

History is that originally listitems were always backed by a container item but the bindings are now used for much more than building windows. It made sense a long time ago.


RE: ListItem fromString and offscreen=True - null_pointer - 2017-02-21

excellent, thanks for confirming.

any change of getting this pull request into 17.1?