Kodi Community Forum
v20 ListItem.setInfo() to InfoTagVideo migration discussion - 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: v20 ListItem.setInfo() to InfoTagVideo migration discussion (/showthread.php?tid=369255)

Pages: 1 2 3


RE: ListItem.setInfo() to InfoTagVideo migration discussion - Roman_V_M - 2022-08-21

Personally, I've decided to stop supporting my addons on "Leia" and below. The reason is that having to develop and maintain a big Python 2 legacy monster at my full-time job I just hate Python 2 and want to be as modern as possible in my pet projects. Besides, as it was said, "Matrix" was released 1.5 years ago and people had plenty of time for upgrade.


RE: ListItem.setInfo() to InfoTagVideo migration discussion - jurialmunkey - 2022-12-11

Bit of thread necro but I've started writing a Python wrapper module for Nexus to ease the transition as much as possible. I'm planning on submitting to official repo but thought it'd be good to get feedback here first.

https://github.com/jurialmunkey/script.module.infotagger

Usage is intended to be as simple as possible for back compatibility with Matrix allowing for a single dictionary of infolabels to be pass with automatic type compliance.

Import as a dependency in addon.xml
<import addon="script.module.infotagger" version="0.0.1" />

Then when you make your ListItem
python:

from infotagger.listitem import ListItemInfoTag

# Make your listitem as normal
li = xbmcgui.ListItem()

# Pass listitem to the infotagger module and specify tag type
info_tag = ListItemInfoTag(li, 'video')

# li.setInfo(infolabels)
info_tag.set_info(infolabels)

# li.setUniqueIDs(unique_ids)
info_tag.set_unique_ids(unique_ids)

# li.setCast(cast)
info_tag.set_cast(cast)

# li.addStreamInfo('video', videostream_values)
info_tag.add_stream_info('video', videostream_values)


As an alternative to the add_stream_info method, there's a method for passing a single dictionary of all stream details. The format of the dictionary is the same as what is returned via JSON RPC for streamdetails to allow for easy passthrough.
python:

"""
stream_details = {
'video': [{videostream_1_values}, {videostream_2_values} ...],
'audio': [{audiostream_1_values}, {audiostream_2_values} ...],
'subtitle': [{subtitlestream_1_values}, {subtitlestream_2_values} ...]}
"""
info_tag.set_stream_details(stream_details)



RE: ListItem.setInfo() to InfoTagVideo migration discussion - scott967 - 2022-12-12

Seems reasonable.  I had created a dict with keys from ListItem.setInfo and values to the corresponding InfoTagVideo setxxx method.  Then used getattr to get the translation.  But had some gotchas as setinfo allows for some types that don't work in in the setxxx methods.  Like "votes" setinfo is a str but setVote needs an int.  And things like "genre" in setinfo allows str or list but setGenre only takes a list.

scott s.
.


RE: ListItem.setInfo() to InfoTagVideo migration discussion - jurialmunkey - 2022-12-12

(2022-12-12, 03:44)scott967 Wrote: But had some gotchas as setinfo allows for some types that don't work in in the setxxx methods.  Like "votes" setinfo is a str but setVote needs an int.  And things like "genre" in setinfo allows str or list but setGenre only takes a list.

Yeah that's what the the try/except TypeError block will handle:
https://github.com/jurialmunkey/script.module.infotagger/blob/02d24a1bcd50927e9f84e56f4bb924a8efc4ce5f/resources/modules/infotagger/listitem.py#L111-L112

If you pass votes as str then the setVote will raise a TypeError which is caught by the exception block. It will then lookup the type from the dictionary and do the conversion to int.

One issue I realised this morning with this approach is going from str to list because str is an array -- e.g. list("Action") becomes ["A", "c", "t", "i", "o", "n"]. Should be able handle this with a simple lambda x: [x] function instead.


RE: ListItem.setInfo() to InfoTagVideo migration discussion - jurialmunkey - 2022-12-16

FYI - Now in Kodi official repo
https://mirrors.kodi.tv/addons/nexus/script.module.infotagger/


RE: ListItem.setInfo() to InfoTagVideo migration discussion - Angelinas - 2023-01-17

(2022-08-13, 16:05)jbinkley60 Wrote: My first main question is whether folks are thinking of creating a new release for their addons for Nexus or try to maintain a common code release between Matrix and Nexus and detect the version number to determine whether to use ListItem.setInfo() or InfoTagVideo ?  Or just let it go for now and ignore the log messages and deal with it in the future when it gets closer to ListItem.setInfo() support being dropp
I just try Nexus and have log
 
Code:
Setting most video properties through ListItem.setInfo() is deprecated and might be removed in future Kodi versions. Please use the respective setter in InfoTagVideo.
in script.tv.show......next.aired next_aired_dialog.py use single code
 
Code:
liz.setInfo(type="Video", infoLabels=infolabels)
to change in InfoTagVideo
 
Code:
 ListItemInfoTag(liz, 'video').set_info(infolabels)
Not big changes just boring message....remove it from Nexus version


RE: ListItem.setInfo() to InfoTagVideo migration discussion - bbaron - 2023-01-21

@jurialmunkey i have another deprecated message which is not implemented in your script:
Code:

"resumetime" in ListItem.setProperty() is deprecated and might be removed in future Kodi versions. Please use InfoTagVideo.setResumePoint()

can you pls implemented it?


RE: ListItem.setInfo() to InfoTagVideo migration discussion - jurialmunkey - 2023-01-22

(2023-01-21, 14:12)bbaron Wrote: @jurialmunkey i have another deprecated message which is not implemented in your script:
Code:

"resumetime" in ListItem.setProperty() is deprecated and might be removed in future Kodi versions. Please use InfoTagVideo.setResumePoint()

can you pls implemented it?

You can get the InfoTagVideo object via _info_tag attribute of ListItemInfoTag class which makes it simple to set:

python:

info_tagger = ListItemInfoTag(listitem, 'video')
info_tagger._info_tag.setResumePoint(resumetime, totaltime)

If you use a dictionary of infoproperties to setProperties, you could handle it easily with something along these lines:

python:

# Init object
info_tagger = ListItemInfoTag(li, 'video')

# Set infoproperties
if 'resumetime' in infoproperties:
info_tagger._info_tag.setResumePoint(time=infoproperties.pop('resumetime', 0.0), totaltime=infoproperties.pop('totaltime', 0.0))
li.setProperties(infoproperties)


Much better to handle yourself rather than me writing a set_properties() implementation for a single key.

The original setProperties() is case insensitive, so I won't know in advance if you use 'resumetime' or 'ResumeTime' or 'resumeTime'. I'd need to iterate and lower() every key in the infoproperties dict to check, which is going to have much worse performance than the above.


RE: ListItem.setInfo() to InfoTagVideo migration discussion - jbinkley60 - 2023-01-27

A question here regarding getVideoInfoTag() and a whether there is a getTags function to get the associated tags for an item.  Looking at the Wiki page I only see a setTags function and no getTags function.  I could use an RPC call or a direct database query but was hoping I could use getVideoInfoTag() to get the associated tags.


Thanks,

Jeff


RE: ListItem.setInfo() to InfoTagVideo migration discussion - zachmorris - 2023-02-11

@jurialmunkey,
Thanks so much for making this script. I'm just testing it out and possibly found a bug? I'm not sure.
Previously, I would set the 'size' parameter with SetInfo. The script currently gives the error:
xml:

[script.module.infotagger] set_info:
KeyError: size

And indeed size isn't in the list here, but there's a list of general keys that apply to all types of list items: count, size, date. See here.

I see 'date' in the list, but not 'count' and 'size'.

Also, one thing of note. I was getting a type error with 'studio' and 'tag', which in my addon was previously a string. script.module.infotagger requires it be a list or tuple, but the docs say:
xml:

studio: string (Warner Bros.) or list of strings (["Warner Bros.", "Disney", "Paramount"])
tag: string (cult) or list of strings (["cult", "documentary", "best movies"]) - movie tag

Not a big deal. I can change that on my side, but unsure if that was purposeful or not.


RE: ListItem.setInfo() to InfoTagVideo migration discussion - jbinkley60 - 2023-02-11

(2023-02-11, 19:22)zachmorris Wrote: Also, one thing of note. I was getting a type error with 'studio' and 'tag', which in my addon was previously a string. script.module.infotagger requires it be a list or tuple, but the docs say:
studio: string (Warner Bros.) or list of strings (["Warner Bros.", "Disney", "Paramount"])tag: string (cult) or list of strings (["cult", "documentary", "best movies"]) - movie tag

There are a few more that went from being either a string or list to a list only with infoTagVideo().  I had to add explicit string splits on the following setInfo variables to make the compatible for: 

setGenres
setDirectors
setWriters
setArtists
setStudios
setCountries

infoTagVideo().  Fortunately for me my source strings for setInfo were already comma separated variables.


Jeff


RE: ListItem.setInfo() to InfoTagVideo migration discussion - jurialmunkey - 2023-02-12

(2023-02-11, 19:22)zachmorris Wrote: Previously, I would set the 'size' parameter with SetInfo. The script currently gives the error:
xml:

[script.module.infotagger] set_info:
KeyError: size

@zachmorris
I was waiting for this one to come up.

As far as I could tell there isn't an equivalent function for setting size in InfoTagVideo. It didn't feel right for me to just ignore without an error.

I found an equivalent for date but not count or size. I'm not certain if these have been depreciated or if these general values were overlooked by Montellese when making the setters.

If anyone knows how to set size and count with the new method I'm very happy to add it but I couldn't see anything in the docs.

I think it might need to be reported on xbmc github as missing because I have a feeling it was overlooked.

(2023-02-11, 19:22)zachmorris Wrote: Also, one thing of note. I was getting a type error with 'studio' and 'tag', which in my addon was previously a string. script.module.infotagger requires it be a list or tuple, but the docs say:

The infotagger module will accept either

It does get converted if it's not in the correct format. I just can't suppress the exception message from Kodi even though I catch it in a try/except block and do a conversion.

In v0.0.4 of infotagger if you specific type_check=True as a parameter of ListItemInfoTag() class then it will force it to do an explicit type check and convert first rather than wait to catch the exception.

Eg in here

Code:

info_tag = ListItemInfoTag(li, 'video', type_check=True)

The reason I don't set this by default is because it adds a very small bit of extra overhead to do an isinstance check on each value and it isn't changing the end behaviour (single string is converted to list either way).

Its only purpose is to avoid the internal exception message from Kodi's C wrapper so I figured by default the extra performance would be preferred. The overhead of type_check is miniscule but I guess it could add up for plugins that set 100s of items.


RE: ListItem.setInfo() to InfoTagVideo migration discussion - zachmorris - 2023-02-12

Thanks. I've opened an issue just to clarify if that method should exist or not.


RE: ListItem.setInfo() to InfoTagVideo migration discussion - zachmorris - 2023-02-15

Just looking over the source for listitem and infotagvideo, it looks like these properties are not yet in the depreciated list:
count, size, overlay, date
So they can still be set with SetInfo (they don't trigger the depreciation warning). However, now I'd have to use both setInfo and set_info to populate everything.

Unsure how easy it would be in script.module.infotagger to treat those special cases somehow? I wasn't able to quickly see one since there's no 'getter' for those either (just the listitem itself).


ListItem.setInfo() to InfoTagVideo migration discussion - jurialmunkey - 2023-02-15

@zachmorris - Interesting. Yeah that should be relatively easy to redirect back to SetInfo for those. I can't see any issue doing that if that's currently the official way to set those specfic properties

I'll have a think about best approach and see what I can come up with.