Skip to content

Frequently Asked Questions

Long-Man edited this page Mar 20, 2021 · 2 revisions

For me, MediaImport both is and isn't a solution, and only partly helps with the big picture. It does help with adding items to the library and metadata. However, does it help with transcoding, remote control sessions, external subtitles and playback reporting?

  • For python add-ons media import is just another extension in Kodi's add-on system. That means that you can combine it with all kinds of other add-on features.

    * The maintainer of the plugin.video.waipu.tv add-on added experimental support for media importing to his add-on without dropping any other features of his add-on. He also provides plugin://plugin.video.waipu.tv based URLs for imported items so playback is still handled through the add-on.

    * In the mediaimporter.emby add-on I have also integrated custom context menu options for items imported through the add-on which e.g. provide additional playback options (direct play vs. streaming) or allow to manually refresh the metadata of an imported item.

  • Based on the previous point transcoding should be possible by using plugin:// based URLs for imported items instead of direct paths or HTTP-based URLs. I'm just not familiar enough with the Kodi's plugin system which is why I haven't adopted it yet. Pull requests are always welcome :-)

  • External subtitles and playback reporting are already fully implemented. To improve the support for external subtitles I even extended the existing python API to be able to provide additional information like the name and language of the subtitle. See xbmc/xbmc#17218 for the respective pull request for Kodi mainline.

  • I'm not really sure what remote control sessions can do and how they work but if you can do it with your current add-on I'm pretty sure you would be able to use the same or similar code combined with media import. Again media import is just another extension capable of directly importing items from other sources into Kodi's library.

My media server already supports UPnP, I would think it will find my media server and use its normal uPNP import methods?

For MediaImport UPnP is restricted to imports from another instance of Kodi. I haven't used or updated the UPnP import for a while but the main problem with non-Kodi UPnP servers is that they often don't implement the Search functionality which is necessary to retrieve all media items of a specific media type. I had to add this functionality to Kodi when I started with media import because it didn't support it either. Furthermore UPnP is limited in the type of metadata it can provide. The experience will be better using the new interface. The UPnP media importer does not support partial synchronization whereas 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.

I already have an addon that already syncs directly to Kodi’s database, why would I need MediaImport?

Media import would take care of this for you. You wouldn't have to write directly to the Kodi database (which is not well received when it comes to support) and you wouldn't have to take care of separating your media data from the rest of Kodi's database / library. The idea is that the add-on provides a way to connect to the media provider (your media server) through some custom settings and then the user can specify which media types (movies, tvshows, musicvideos) to import. Then Kodi calls the add-on to provide all media items of a specific media type. The add-on retrieves the items and passes them back to Kodi which takes care of synchronizing them into the database. Obviously there are some advanced concepts like partial synchronization etc. but this should give you a general idea.

How are watched status, playstate and progress reported back to the server?

Media import supports a specific workflow to report changes to the imported media items back to the media provider (in your case the media 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.

eg. the Emby media importer reports playback progress back to the server every few seconds and in the Emby server dashboard you can see that playback is active in Kodi.

How is syncing handled in MediaImport? Do I need to write code for syncing?

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.

Right now there is no scheduled synchronization (identical to the "normal" library scan / update) but it would be very easy to add.

What version of Kodi does a mediaimporter addon needs to support, Krypton, Leia or Matrix?

Since media import is not part of Kodi mainline there's no need to support anything else but Matrix+. In addition the importer must be written in Python 3.

Do I need to write my own settings dialog for autheniticating etc for my mediaimporter addon?

You can if you want extra fetures beyond just authenticating, importing and syncing mediaitems but it is not a requirement. 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.

My current Kodi addon provides features beyond media syncing, will I lose these features by moving to MediaImport?

No you wouldn’t lose them. 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.

Take for example the Emby media importer, it 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.

Does MediaImport take all of the metadata from the addon vs. rescraping the data?

The metadata comes from the mediaserver via the addon. MediaImport does not rescrape the data. Media importer add-ons must provide their media items as ListItems (see https://codedocs.xyz/AlwinEsch/kodi/grou...titem.html). 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.

How does MediaImport handle deletions on the server?

Media import adds additional tables to the database which keeps track of which media item has been imported from where. Now when an item is removed from the server there are two possible scenarios:

  • The media importer (add-on) does a full sync. Kodi then retrieves all previously imported media items and compares them with the list of "newly" provided media items. All items which are part of the list of already imported items but not part of the list of "newly" provided media items will then be removed from the database.
  • The media importer (add-on) detects that the media item has been removed from the server (Emby, Jellyfin and Plex support this) and tells Kodi through the media importer interface that the item has been removed. It is then automatically removed from the database.

Further, for partial synchronization there are two possibilities:

  1. The media importer (add-on) simply provides a list of changed (added or updated) media items and Kodi determines which ones are new and which ones have changed. This approach does not support removing imported media items.
  2. The media importer (add-on) provides a list of changed (added, updated or removed) media items with an additional flag for each item which specifies the type of change. Kodi then takes care of either adding, updating or removing the media items depending on the specified type of change.

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). Addons for Emby and Plex are included in the repo
  • 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

NB. In Addition Add-on media importers can provide any other additional functionality which is not media import specific