WIP Media importing and library integration (UPnP, Emby, Plex, ...)
(2021-03-01, 23:20)jbinkley60 Wrote: When I say separate in the Kodi database I simply mean I track records belonging to Mezzmo vs. not.  As far as the user goes, if they are displaying data from the native Kodi front end vs. using the Mezzmo addon GUI, they won't be able to tell the difference.  I believe this is similar to how it looks like MediaImport operates.  The Mezzmo addon just simply plays nice with other data and is a good citizen.  The JSON RPC comment was simply looking at moving from the current direct SQL access to JSON RPC to populate / maintain data which is what the Wiki says is preferred.  I've had minimal luck finding any documentation on this and would have concerns about performance.  This was just part of a conversation LongMan and I were having and not really related to MediaImporter other than I originally thought that is how MediaImprotter was updating the database.
Sorry I misunderstood the part about JSON-RPC. Since I've written most of the JSON-RPC logic a few years ago and there hasn't been much activity there I'm pretty sure that it's not possible to build your database purely through JSON-RPC and the performance would be bad as well. 
(2021-03-01, 23:20)jbinkley60 Wrote: I've done some additional reading on the Wiki page and looking at the other importer addon code.  I have a better understanding of MediaImport in that it is native to the Kodi code and not another addon.  It uses an extension point for media provider addons.  I looked through some of the Emby code and many of the various functions it has Discovery, Import etc..  are already written in the Mezzmo addon but operate a bit differently due to having a GUI, leveraging some Mezzmo specific functions and similar.
For some things you are also free to use GUI dialogs in media importer add-ons. Every detected media provider has a settings dialog which directly interacts with the media importer add-on. As an example the Plex media importer add-on supports authentication through a PIN. When the user clicks the (add-on defined) button to start authentication the add-on's callback handler is called which asks plex.tv for a new PIN and displays it to the user. The user then has to enter that PIN on a plex website which will automatically be detected by the add-on which then retrieves the access tokens and stores them in the settings.
(2021-03-01, 23:20)jbinkley60 Wrote: In addition there are a number of features in the Mezmo addon which are unique or operate differently.  Playcounts, bookmarks and such are passed back to the Mezzmo server for all clients to leverage.  Likewise you can mark watched and unwatched via the GUI and it sets it in the Mezzmo database for all clients.
These are not at all unique to Mezzmo. Media import supports a specific workflow to report changes to the imported media items back to the media provider (in your case the Mezzmo server). A media importer add-on can provide a callback for this and Kodi takes care of calling this callback with any changed media items. This works for playback, mark as watched / unwatched etc. The Emby media importer e.g. reports playback progress back to the server every few seconds and in the Emby server you can see that playback is active in Kodi.
(2021-03-01, 23:20)jbinkley60 Wrote: The GUI has view over rides so the user can remap a view to their preference overriding the default view for the media type.  The bookmarks are user adjustable for 0-30 seconds behind where you stop in case you want to rewatch the last few seconds.
Since a media importer add-on is just an add-on implementing a specific extension point nothing is stopping you from providing additional extension points and features. The Emby media importer e.g. provides additional custom context menu entries. In the Plex media importer add-on I'm working on integrating the skip intro feature which has nothing to do with media import except that it can be applied to the imported media items.
(2021-03-01, 23:20)jbinkley60 Wrote: As mentioned earlier, full synchronization is built-in including detecting Mezzmo database metadata changes, a daily sync process and more.
Media import support full and partial synchronization. At the beginning it always performs a full synchronization but then (depending on the add-on) it can automatically provide items changed on the server without a manual synchronization. Both Emby and Plex media importers support "fast synchronization" after a full synchronization which only retrieves all changed media items since the last synchronization.
(2021-03-01, 23:20)jbinkley60 Wrote: Because of all of this and other integrated functionality it would likely be better to write a new addon for MediaImporter and leverage code from the existing addon.  It's going to be a piece of work and I have a number of questions on how MediaImporter works and the interface to an addon.
I'm not sure whether this is true. You probably already have all of the necessary code but in a different design. I'm pretty sure you could re-use a lot of it and just put it into different places and use different interfaces.
(2021-03-01, 23:20)jbinkley60 Wrote: I'd also only do a Matrix version and not maintain 2 code versions.
Since media import is not part of Kodi mainline there's no need to suppor anything else but Matrix+.
(2021-03-01, 23:20)jbinkley60 Wrote: First, how are you handling uPNP server record deletions ?  I handle it in Mezzmo via a daily sync process which runs between midnight and 6AM.   The sync processes detects when nothing is playing and runs in the background.  The daily sync removes all Mezzmo records from the Kodi database and then does a new bulk import.  This takes care of deleted records.  I also detect duplicate records in the Mezzmo database.  I am unaware of uPNP servers having the ability to let you know of a deleted record so a full sync seemed to be the best option.  It also makes it nice if a client needs to be rebuilt or the Kodi DB goes haywire.  The addon rebuilds it as soon as it starts.  I am curious how you handle this ?
The UPnP media importer does not support partial synchronization. Also doing a full import every day would probably be too slow right now (but I'm currently looking into performance). The media import logic contains a lot of code to compare the already imported media items with the newly provided media items. It detects whether items have changed or have been added and removed and only makes the changes to the database which are necessary. If an item hasn't changed between imports it isn't touched. Right now there is no scheduled synchronization (identical to the "normal" library scan / update) but it would be very easy to add.
(2021-03-01, 23:20)jbinkley60 Wrote: Second, does MediaImporter take all of the metadata from the addon vs. rescraping the data ?  If so, what format is needed from the addon ?  The Mezzmo addon gets an XML response and parses it prior to adding to the Kodi database.  In looking at the Emby importer code it looks like you might be doing a field mapping but I can't tall what the exact structure is of the uPNP metadata going to MediaImporter.
Media importer add-ons must provide their media items as ListItems (see https://codedocs.xyz/AlwinEsch/kodi/grou...titem.html). UPnP isn't involved and the media import logic doesn't care whether the information was originally retrieved as XML or JSON or anything else because it is the add-on's responsibility to transform this into a list of ListItems. In your Mezzmo add-on you currently take the XML and turn it into SQL queries. In a media importer add-on you turn it into ListItems.

As a general roundup I'm just putting out a few buzz words to try to describe the feature set of media importing:
  • Media items can be imported from multiple providers (servers) coexisting. For each provider the user can create imports of specific media types.
  • Media import uses generic interfaces everywhere: for importers, databases, media type handlers, ...
  • The following media types can currently be imported:
    • movies and sets / collections
    • tvshows, seasons and episodes
    • music videos
  • The following importers are currently supported:
    • UPnP (hardcoded in Kodi core)
    • add-ons (new extension point)
  • A media importer can support the following features
    • automatic provider discovery
    • manual provider discovery (with user interaction)
    • full (and optionally partial) synchronization
    • observing imported providers / imports for changes and synchronizing them with the Kodi library
    • passing changes to imported media items from Kodi back to the media provider
  • Add-on media importers can provide any other additional functionality which is not media import specific
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply


Messages In This Thread
Unexpected Behaviour - by LongMan - 2015-04-20, 23:53
RE: Media importing and library integration (UPnP, Emby, Plex, ...) - by Montellese - 2021-03-02, 08:15
20.2 Generic Builds - by LongMan - 2023-07-20, 04:49
Logout Mark Read Team Forum Stats Members Help
Media importing and library integration (UPnP, Emby, Plex, ...)10