Setting property via json to tvshows/movies
#1
Hi, I want to create a service add-on that auto-play trailers. This is something I have working half via my skin and half via my python script.
But I wish to move this to service-based python addon because I believe it will work better and be more modular.
I wish to 'scrape' trailer result from youtube and assign it a property in tvshow/movie items of kodi's library. The whole idea is doing this on library update and/or cache interval, so when I want to call the player it wouldn't require doing this search each time (multiple requests for same query) and will be fast because we just need to fetch the already set trailer path.

PROBLEM: How can I set a property to kodidb item? If the item is supplied by a plugin I know how-to do that but not for a library-supplied content.
to my understanding, I need to use the json api to achieve this but tvshows don't have 'trailer' param (and even if they did, like movies, i don't want to override the one given by scraper).
So, I'd like having something like ListItem.Property(Trailer), but is that possible?
The only path I see currently is using 'tags' like stinger does for 'aftercredits' etc. but is it really the only way?
Reply
#2
Looks like you want just to save data and read it later for your skin/plugin thing ?
If so you can simply get db id and save pair of 'id' , 'url_trailer' inside small sqlite database stored inside speciall:// plugin folder which is in /userdata/addonname/ this is not wipe when you update your plugin/addon so it will be there after updates.

That way you don't save unneeded data inside tag, and you wont overwrite the proper trailer, or first you can try to check if scraper did find trailer, if no save new one there, if yes save new in sqlite database, that way you give your user better experience because all tvshows will have trailer for build-in support.

Any Kodi internal database operations are mainly done thru JSON-RPC
Reply
#3
(2019-04-15, 07:20)bigretromike Wrote: Looks like you want just to save data and read it later for your skin/plugin thing ?
If so you can simply get db id and save pair of 'id' , 'url_trailer' inside small sqlite database stored inside speciall:// plugin folder which is in /userdata/addonname/ this is not wipe when you update your plugin/addon so it will be there after updates.

That way you don't save unneeded data inside tag, and you wont overwrite the proper trailer, or first you can try to check if scraper did find trailer, if no save new one there, if yes save new in sqlite database, that way you give your user better experience because all tvshows will have trailer for build-in support.

Any Kodi internal database operations are mainly done thru JSON-RPC
Yep, that sounds like a good approach.
Do you know of an example add-on for this db-addon interaction that I can learn from to apply to my own?
Reply
#4
(2019-04-15, 14:28)cartman.dos Wrote:
(2019-04-15, 07:20)bigretromike Wrote: Looks like you want just to save data and read it later for your skin/plugin thing ?
If so you can simply get db id and save pair of 'id' , 'url_trailer' inside small sqlite database stored inside speciall:// plugin folder which is in /userdata/addonname/ this is not wipe when you update your plugin/addon so it will be there after updates.

That way you don't save unneeded data inside tag, and you wont overwrite the proper trailer, or first you can try to check if scraper did find trailer, if no save new one there, if yes save new in sqlite database, that way you give your user better experience because all tvshows will have trailer for build-in support.

Any Kodi internal database operations are mainly done thru JSON-RPC
Yep, that sounds like a good approach.
Do you know of an example add-on for this db-addon interaction that I can learn from to apply to my own? 

Sadly know, I don't know any simple examples out there, but the best way you can do it to search thru github, I search there my self, get the short command that i want to use, filter by python code and most of the time end up with some small plugins that use it.

I could link you to https://github.com/bigretromike/nakamori  but that's not a simple example anymore :-) after our last rewrite its now a monster addon ;-)
Reply

Logout Mark Read Team Forum Stats Members Help
Setting property via json to tvshows/movies0