[DATABASE] Database Update API?
#1
Question 
Not entirely sure if this is the best place to ask about this, but thought it worth a shot - still, feel free to point me in the right direction if I'm wrong.

Basically, I've recently started using MySQL as the back-end database, and I thought it would be useful for external content providing sources (e.g. sickbeard) to be able to update the MySQL database when the XBMC instance isn't running. To put it another way - the database will always be available, but the XBMC instance will only be switched on when in use, so updating the database is possible, but telling XBMC to do it isn't. The use case is that there's a central database storing media information (which is already catered for with the MySQL backend that's in place) which needs to be updated by a third party tool (sickbeard, for example) when new episodes are added or when a file is changed (e.g. video quality, encoding information) that has access to the MySQL database but there isn't a running XBMC instance on the network.

To that end, I did a little digging, and found that the database access is abstracted away - good news. What I've been unable to find so far is whether there exists an API for library updates that can be used by an external program running on a remote system (e.g. on my server).

If I've understood things correctly, this isn't a feature request because (I assume) the database access code is abstracted behind an API layer, so the feature/code already exists. In theory, all I need is information about that API layer so that my external library update process can call that API to update the MySQL database. I just can't work out where the code is, or what this API might allow in real terms, or even whether it's currently possible for a third party codebase to access that API at all.

So... have I understood things correctly, or am I wrong and this needs to be a feature request?
Reply
#2
Nothing is abstracted to the point you would require (i.e. you can't just dynamically link to the portion of the XBMC code you need).

It would be a welcome modification, however to get this cleaned up - I suspect it's not a trivial task though!

The scanning/scraping is done in VideoInfoScanner and MusicInfoScanner and their related classes. These then interface directly with CVideoDatabase/CMusicDatabase and their ilk.

Cheers,
Jonathan
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#3
I have similar interests - more abstraction, less dependency on a big monolithic GUI application - so would be happy to hear whatever ideas you have here. If you're a developer, take a look at 214 (PR) which makes XBMC a shared library which can be used by other programs (there is an example of one in this thread: http://forum.xbmc.org/showthread.php?p=822016). I'm currently using it to build a test infrastructure for scrapers (most likely by writing a Python interface since that makes testing using e.g., the unittest module, more convenient).

Further separation of XBMC code into libraries with sharp demarcations (rather than as now with e.g. GUI code intermingled everywhere) would be an improvement. I was originally hoping to be able to extract scrapers alone, for example, into a library, but it proved harder than expected which is why I created one big library instead. But it can and should be further broken down. (Note that having static libraries, while helpful to a point, does not provide a true demarcation, since there is no limitation on what may be called or call in from elsewhere in the code.)

Another idea that would be helpful (and help with the synchronization issues that might crop up with having two applications accessing the database) is to do like MythTV does and break XBMC into a frontend GUI and backend server process. There is of course a large JSON RPC interface and Python (and other language) addon/plugin interface too (and a couple more - DBus, at least, but it seems pretty limited, although I think I saw something about it going in as a new language in the work being done by jfcarroll).

There is probably room for more abstraction, but you probably can get pretty far linking to libxbmc.so using my code above and just using the classes and functions in the XBMC code base from your updater application. I am hoping that library change will be committed before too long.
Reply
#4
dbrobins Wrote:I have similar interests - more abstraction, less dependency on a big monolithic GUI application - so would be happy to hear whatever ideas you have here.

I was approaching this from the perspective of having a single server back-end with multiple client instances of xbmc, as I suspect that this is where ultimately most installs are likely to end up. After all, once you have one XBMC, you're only going to want more of them, and then it becomes more convenient to share the configuration and libraries and so on with some sort of remote server. In my case, I already have a server machine running things like postfix, MySQL, nginx, dovecot, samba, couchpotato, sickbeard and so on so it would make sense if that machine could maintain the XBMC library.

My background is in service oriented architectures, and I thought that having the data access component of XBMC as a service would be ideal. If it's a background service (e.g. a daemon or windows service or web service or whatever) then it could be fired up anywhere and on any machine to do the interaction with the XBMC data (initially for the media libraries, but this could be expanded to include system settings, I suppose, if there are any that make sense to be shared such as samba mappings) without the need for the front end. Ultimately, XBMC itself could also use this service to perform its library access thereby abstracting that component entirely away from the front end so that the front end doesn't care.

This is why I was asking whether there was a defined interface already in XBMC that could/should be used - if there was, I can simply code against that API to create this service. If this doesn't exist, then I've got some investigative work to do to start putting one together before any development work can start.

dbrobins Wrote:If you're a developer, take a look at 214 (PR) which makes XBMC a shared library which can be used by other programs (there is an example of one in this thread: http://forum.xbmc.org/showthread.php?p=822016). I'm currently using it to build a test infrastructure for scrapers (most likely by writing a Python interface since that makes testing using e.g., the unittest module, more convenient).

Thanks! I'll have a look over that when I get a chance - might be that it's already most of the way toward what I'm thinking of. Personally, I've always been a fan of keeping the architectural layers of an application as clean and distinct as possible, but moving a project as complex as XBMC into a new architecture is no small matter, so it's probably likely to be quicker and easier to pull out interfaces and features where it makes sense to do so to make it an incremental shift.
Reply

Logout Mark Read Team Forum Stats Members Help
[DATABASE] Database Update API?0
This forum uses Lukasz Tkacz MyBB addons.