Guest - Testers are needed for the reworked CDateTime core component. See... https://forum.kodi.tv/showthread.php?tid=378981 (September 29) x
Would it be possible to create an add-on that updates a library from a JSON file?
#1
Hi all

I've been wondering for some time if it would be possible to create an addon that would make it possible to update your library based on a remote JSON file, instead of iterating over a fileshare.

It looks like https://kodi.wiki/view/Plugin_sources would be a possible way to do this, but it is not really clear to me if such a source can supply a webdav path when it comes to actually playing the media.

Also, does a plugin source work in such a way that KODI will retrieve information about the media from scrapers, just as it would if it was a SMB share?

I haven't been able to find any source for a plugin source add-on anywhere to look at for inspiration either. Smile
Reply
#2
video addons use plugin source to indicate they are video addons f.e. https://github.com/matthuisman/slyguy.ad.../addon.xml

they do not provide library functionality though, in order to do so you need to implement "medialibraryscanpath" an example addon is here https://github.com/Dis90/plugin.video.testlib

however, this is broken in kodi and will most usually crash kodi when scanning an addon's content as library content, reported as fixed however my own testing shows it still crashes on Debian with Kodi 21
- https://github.com/xbmc/xbmc/issues/23636

here is a link to the thread where i last tried to create such an addon https://forum.kodi.tv/showthread.php?tid=374003
the code is gone but you can see the example from Dis90 above as it does the same thing

-----

that's a long way of saying yes it should work but in reality does not
Reply
#3
I don't have experience with Kodi's content libraries as I use Python video-folder plugins only, but the libraries themselves are stored in the userdata sqlite3 databases, yes?

Therefore, I imagine you could import the (built-in) sqlite3 package in Python, then manually connect to the database, update it with the contents of whatever you want (like from that JSON file), then commit to it and finally close the database (and optionally command Kodi to reload the current profile in case that's not enough to have it update the displayed content from the database).

You can use SQLiteStudio (FOSS) to open and study Kodi's databases:
https://github.com/pawelsalawa/sqlitestudio

As well as the official docs:
https://kodi.wiki/view/Databases/MyVideos

For code reference, using Python to modify the MyVideos database to clear the playcount of a specific group of items: 
https://forum.kodi.tv/showthread.php?tid=378798
Reply
#4
Yes, direct updates via SQLite is entirely possible, as well as from a JSON source.  I do similar with an XML source with a full sync to Kodi video library, including almost all fields (there are a couple of fields my XML source doesn't provide).   It is a bit of coding though, especially to handle changes vs. just a one time population or additions only.  There are a number of tables in the video library.  With my addon I sync all Kodi clients to a central database and never touch the Kodi client databases (i.e. no Kodi scrapers etc..) via Kodi, the addon does all the updating.

If you want to see some of my code you can look at it here.

I am happy to answer questions.

Thanks,

Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#5
directly modifying the kodi database should not be attempted by novice users

just a disclaimer, do as you wish
Reply
#6
(Yesterday, 05:28)izprtxqkft Wrote: directly modifying the kodi database should not be attempted by novice users

100% agree.  It's quite a bit of work and complexity, along with keeping up with the various Kodi database versions and changes.


Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply

Logout Mark Read Team Forum Stats Members Help
Would it be possible to create an add-on that updates a library from a JSON file?0