Kodi Community Forum
WIP Media importing and library integration (UPnP, Emby, Plex, ...) - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93)
+--- Thread: WIP Media importing and library integration (UPnP, Emby, Plex, ...) (/showthread.php?tid=224794)



RE: Media importing and library integration (UPnP, Emby, ...) - Mettbrot - 2017-04-30

I don't know if Montellese is happy with the UPnP implementation as it is right now. I recall, he was considering moving the whole thing from platinum SDK to OhNet since platinum isnt really developed anymore.
This seems to be a huge amount of work though.. https://github.com/Montellese/xbmc/commits/ohnet
Maybe something for GSoC?


RE: Media importing and library integration (UPnP, Emby, ...) - Montellese - 2017-04-30

(2017-04-28, 15:40)natethomas Wrote: It seems like this project is pretty far along, montellese. Would it make sense to PR it in and let the team work on any remaining bugs?

There are basically three problems with this right now (apart from any known/unknown bugs):
  1. I most likely won't have time to take care of any bugs and issues this would cause which would result in a huge additional burden on other developers.
  2. The implementation only covers videos and music hasn't been done yet.
  3. Right now the only way to write media imports is in C++. I would prefer it if we had a python add-on interface which would make it a lot easier for other people to write imports for Emby, Plex et al.

(2017-04-30, 11:20)Mettbrot Wrote: I don't know if Montellese is happy with the UPnP implementation as it is right now. I recall, he was considering moving the whole thing from platinum SDK to OhNet since platinum isnt really developed anymore.
This seems to be a huge amount of work though.. https://github.com/Montellese/xbmc/commits/ohnet
Maybe something for GSoC?
Well that's not really a necessity for this work. It would allow a bit more flexibility and additional integration like downloading imported items for offline viewing but the basics needed work fine with the existing platinum SDK.


RE: Media importing and library integration (UPnP, Emby, ...) - jjd-uk - 2017-04-30

For the Media Importers could the python scraper interface be extended to cover this?


RE: Media importing and library integration (UPnP, Emby, ...) - Montellese - 2017-04-30

(2017-04-30, 12:20)jjd-uk Wrote: For the Media Importers could the python scraper interface be extended to cover this?

I don't really know what that interface currently looks like. Right now the interface to be implemented by a media importer is defined by https://github.com/Montellese/xbmc/blob/media_import/xbmc/media/import/IMediaImporter.h. The imporant parts are:
  • GetIdentification(): this should be easy as the add-on already has an ID and a name.
  • ProvidesChangeset(): whether the add-on provides a full list of imported items or only a changeset since the last synchronisation.
  • CanImport(): whether the add-on is capable of importing items from a given path.
  • LoadSourceSettings() / LoadImportSettings(): the add-on can provide media provider / import specific settings. This is the reason why I started working on getting add-ons to use the same settings system as kodi again.
  • Import(): the add-on gets a list of already imported items and then more or less returns a full list or a changeset of imported items

Furthermore the add-on would probably need some kind of service component which tells kodi about available media sources which the user can import items from.


RE: Media importing and library integration (UPnP, Emby, ...) - angelblue05 - 2017-05-22

@Montellese

I'd like to help with the python portion if possible. Just let me know what needs to be done and where I should start.

Quick question about paths for items: Let's say the user uses Kodi locally or outside their network. In Emby for Kodi, we use plugin paths to accommodate the scenario where the path of the content may change depending on the user's location. What flexibility do we have in this regard? Does this only support direct paths to content or?


RE: Media importing and library integration (UPnP, Emby, ...) - Montellese - 2017-05-23

Right now the UPnP importer simply uses UPnP paths which can already be resolved by Kodi. But this is a problem I'm aware of. We might need some kind of URL resolver plugin infrastructure which would allow a media importer plugin to also provide an URL resolver implementation and then use its own URLs for imported items.

As soon as I've finished my add-on settings work I'll come back to media importing (which should benefit from the add-on settings work) and then I'll look into how this could be done for python add-ons. Most of the things mentioned above should be straight forward but the Import() part requires that Kodi provides the plugin with a list of already imported items and AFAIK this hasn't been done anywhere in the existing plugin API yet. I'll let you know as soon as I've got something to work with / against.


Media importing and library integration (UPnP, Emby, ...) - angelblue05 - 2017-05-23

That's good to hear. I'll be here Smile


RE: Media importing and library integration (UPnP, Emby, ...) - LongMan - 2017-06-07

Big Grin Awesome.


RE: Media importing and library integration (UPnP, Emby, ...) - Montellese - 2017-06-07

I've actually spent quite a bit of time on the python add-on integration in the last few days. It's still highly WIP and my python skills suck (I basically have to look up every other method call) but I've put together a python add-on at https://github.com/Montellese/xbmc/tree/media_import/addons/mediaimporter.emby which should basically replace the WIP I wrote in C++ for importing items from Emby. It's still very basic and therefore a lot of things are missing:
  • the new API in the xbmcmediaimport module doesn't support handling media provider and media import settings yet
  • the new API in the xbmcmediaimport module is completely undocumented
  • the new add-on doesn't handle user authentication (it simply uses a hardcoded API key) which requires media provider settings (see above)
  • the new add-on doesn't handle library views and everything is hardcoded

For the new add-on type it basically comes down to
  • providing a service script which is responsible for discovering and registering media providers through the xbmcmediaimport module
  • providing a library script which can handle different actions with the most important ones being "canimport" and "import" where for import you get a path and a list of media types to import and then you can do some magic, create ListItems and pass them back to Kodi which will then properly handle them as imported items.

Does that sound reasonable? I've basically looked at how plugin add-ons work and copied / refactored a lot of that. Once again I am no python developer so I have no idea what a sensible python API looks like Wink


RE: Media importing and library integration (UPnP, Emby, ...) - LongMan - 2017-06-09

I made a post about this in the Emby for Kodi forum. Hopefully one of the devs will respond. Is there a build which I could use to give this a spin?


RE: Media importing and library integration (UPnP, Emby, ...) - Montellese - 2017-06-09

(2017-06-09, 18:38)LongMan Wrote: I made a post about this in the Emby for Kodi forum. Hopefully one of the devs will respond. Is there a build which I could use to give this a spin?

I've triggered a win32 build on jenkins: http://jenkins.kodi.tv/job/WIN-32/4904/

Just remember, as I said this python integration is still very much work in progress Wink

EDIT: And here's the link to the test build installer: http://mirrors.kodi.tv/test-builds/win32/KodiSetup-20170607-471a7b1-media_import-x86.exe


RE: Media importing and library integration (UPnP, Emby, ...) - LongMan - 2017-06-09

Thanks. I will keep that in mind.


RE: Media importing and library integration (UPnP, Emby, ...) - LongMan - 2017-06-10

A possible description could be;

"Emby Media Importer allows you to import and play media libraries, for movies, tv shows and music videos, from Emby Media Server. Thus using Emby as a metadata manager (server) and Kodi as player (client). In addition playback data can be synced across multiple clients, for each User on Emby."


RE: Media importing and library integration (UPnP, Emby, ...) - LongMan - 2017-06-10

I installed it over the previous build, it pops up the dialog to say it is syncing but nothing syncs. I assume it is using the media import settings, at least a part of it, from the C client. Seeing that there are no settings for the python addon yet.


RE: Media importing and library integration (UPnP, Emby, ...) - Montellese - 2017-06-10

(2017-06-10, 02:17)LongMan Wrote: A possible description could be;

"Emby Media Importer allows you to import and play media libraries, for movies, tv shows and music videos, from Emby Media Server. Thus using Emby as a metadata manager (server) and Kodi as player (client). In addition playback data can be synced across multiple clients, for each User on Emby."
Since I don't really plan on maintaining that add-on it's not really worth having a proper description etc. I'm only writing this as a proof of concept so that other peopel with more python and kodi add-on skills can do something better and have an example of how the API is supposed to be used. But thanks.

(2017-06-10, 02:48)LongMan Wrote: I installed it over the previous build, it pops up the dialog to say it is syncing but nothing syncs. I assume it is using the media import settings, at least a part of it, from the C client. Seeing that there are no settings for the python addon yet.

Yeah because I haven't implemented the whole settings stuff into the python API yet I have hardcoded an Emby API key and don't care about library views etc. Furthermore I have commented the last line of the import logic which would tell Kodi that importing went fine because there is some problem with the ListItem.setInfo() call a few lines further up which is borking some of the properties and I haven't figured out why yet.


This forum uses Lukasz Tkacz MyBB addons.