Kodi Community Forum
Confused - listitems, set_info, & InfoTagVideo, and offscreen list items not working - 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: Confused - listitems, set_info, & InfoTagVideo, and offscreen list items not working (/showthread.php?tid=379301)



Confused - listitems, set_info, & InfoTagVideo, and offscreen list items not working - bossanova808 - 2024-10-30

Ok, so I have a JSON playlist I am loading in a plugin, which has the correct info I need available:

json:

{
    "file": "C:\\Kodi\\Kodi Library\\TV01\\Celebrity Letters and Numbers\\Season 01\\Celebrity_Letters_And_Numbers - S01E01 - 720p WEBDL.mp4",
    "type": "episode",
    "source": "Kodi Library",
    "dbid": 7,
    "title": "Episode 1",
    "thumbnail": "http://thetvdb.com/banners/v4/series/410533/backgrounds/615baa38ca034.jpg",
    "fanart": "http://thetvdb.com/banners/v4/series/410533/backgrounds/615baa38ca034.jpg",
    "year": 2021,
    "showtitle": "Celebrity Letters and Numbers",
    "season": 1,
    "episode": 1,
    "resumetime": 47.176,
    "totaltime": 2981.4,
    "artist": "",
    "album": "",
    "duration": 0
},

When my plugin is called in one mode (<z mod="ctrl">PlayMedia(plugin://script.switchback/?mode=play_previous,resume)</z>) - it loads that json and builds an (offscreen) listitem, before it sets the resolved URL to trigger playback (xbmcplugin.setResolvedUrl(plugin_instance, True, list_item)).  That works, and playback begins.

What I want to happen is all that useful info to be provided to the player...I believe the idea was to use set_info to do this, and is now to instead use InfoTagVideo - is that right?

I have tried all manner of both set_info and InfoTagVideo, and am currently using https://github.com/jurialmunkey/script.module.infotagger to do this:

python:

    list_item = xbmcgui.ListItem(label=label, path=playback.file, offscreen=offscreen)
    tag = ListItemInfoTag(list_item, 'video')

    infolabels = {
            'mediatype': playback.type,
            'dbid': playback.dbid,
            'title': playback.title,
            'year': playback.year,
            'tvshowtitle': playback.showtitle,
            'episode': playback.episode,
            'season': playback.season,
            'duration': playback.totaltime,
    }
    # list_item.setInfo("video", infolabels)
    tag.set_info(infolabels)
    # Auto resumes just won't work without these, even though they are deprecated...
    list_item.setPath(path=playback.file)
    list_item.setArt({"thumbnail": playback.thumbnail})
    list_item.setProperty('TotalTime', str(playback.totaltime))
    list_item.setProperty('ResumeTime', str(playback.resumetime))
    list_item.setProperty('StartOffset', str(playback.resumetime))
    list_item.setProperty('IsPlayable', 'true')
    list_item.setArt({"poster": playback.thumbnail})
    list_item.setArt({"fanart": playback.fanart})

Once the item is actually playing, I have a listener to onAVStarted which waits a couple of seconds then calls the JSON RPC Player.GetItem - but no matter what data I provide in either the tag or info labels, it always comes back with:

Code:

2024-10-30 13:07:56.432 T:14240   debug <general>: ### Switchback 0.0.1: KODI JSON RPC result: {"id":"Player.GetItem","jsonrpc":"2.0","result":{"item":{"episode":-1,"fanart":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fv4%2fseries%2f410533%2fbackgrounds%2f615baa38ca034.jpg/","label":"Celebrity Letters and Numbers (1x01) - Episode 1","season":-1,"showtitle":"","thumbnail":"","title":"","type":"unknown","year":0}}}

... i..e none of that data is actually getting to the player, it seems....but it should, right?  Or am I misunderstanding things here?

I note that when I playback from a visible playlist (as opposed to the PlayMedia command) - then it does in fact seem like the info is getting through:

Code:

2024-10-30 13:31:41.173 T:27608   debug <general>: ### Switchback 0.0.1: KODI JSON RPC result: {"id":"Player.GetItem","jsonrpc":"2.0","result":{"item":{"episode":1,"fanart":"image://http%3a%2f%2fthetvdb.com%2fbanners%2fv4%2fseries%2f410533%2fbackgrounds%2f615baa38ca034.jpg/","id":7,"label":"Episode 1","season":1,"showtitle":"Celebrity Letters and Numbers","thumbnail":"image://video@C%3a%5cKodi%5cKodi%20Library%5cTV01%5cCelebrity%20Letters%20and%20Numbers%5cSeason%2001%5cCelebrity_Letters_And_Numbers%20-%20S01E01%20-%20720p%20WEBDL.mp4/","title":"Episode 1","type":"episode","year":2021}}}

So...ultimately the question is why does this not work with my dynamically created list item?  (I tried setting the offscreen parameter to false, no change) ... and can I fix this?

Help much appreciated - I've done several scripts, some even fairly complex ones, but I am new to plugins and am quite confused at this point...


RE: Confused - listitems, set_info, & InfoTagVideo, and offscreen list items not working - MoojMidge - 2024-10-30

Try adding the playlist_type_hint=1 parameter to your PlayMedia call and see if it makes any difference.

What do you actually see in the playlist window after starting playback? Are the infolabels updated?

If so could try see if https://kodi.wiki/view/JSON-RPC_API/v13#XBMC.GetInfoLabels with these https://kodi.wiki/view/InfoLabels#Video_player works any better.


RE: Confused - listitems, set_info, & InfoTagVideo, and offscreen list items not working - bossanova808 - 2024-10-31

Well the thing is, I am not playing back from the playlist window - the playback triggered from elsewhere (say from home, or somewhere in the video library) - by aremote key. 
I have tried adding playlist_type_hint=1 just now, but no change.

If I view the playlist manually, it looks as expected:

Image

The issue is the _player_ is not getting this information when doing the playback.  I mean - all the labels look right, but when I retrieve things via the JSON-RPC via Player.GetItem, they are all empty.

But - it seems your idea of using the VideoPlayer.* etc labels is the way to go - thanks!  That appears to be working a lot better!

Need to do some more testing to see if it solves all the issues but in a quick test all those things seem to be populated as one would expect - awesome!


RE: Confused - listitems, set_info, & InfoTagVideo, and offscreen list items not working - bossanova808 - 2024-11-02

Just following up to say that using the VideoLibrary.* labels was indeed definitely the way to go - many thanks for your help @MoojMidge!