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, ...) - LongMan - 2019-08-30

@DaveBlake
Here is a video that outlines what media import does. If you want to try it to see how it works for video, I found a previous test build that you could use.

Cheers,
LongMan


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

So since there has been some discussion here I thought I'd provide what I remember from almost three years ago (which might be a bit fuzzy):
* The latest state of the work is located in the media_import branch on my github fork of kodi.
* The list of known bugs / TODOs in https://forum.kodi.tv/showthread.php?tid=224794&pid=1986018#pid1986018 is still pretty much up-to-date. Most of them are non-essential. IMO the architecture works.
* There is only support for videos because I first wanted to get that right before tackling music (and I don't use music that much in Kodi).
* IMO the only way this will ever really have an impact is if media imports can be written as python plugins. Writing them in C++ as part of Kodi may offer more immediate options for the developer but the barrier is also much higher. That's what I've been working on last with the Emby demo add-on. The main problem right now is that the add-on settings system is too static. You can't populate a setting option with a dynamic list of choices. This was very easy in my initial C++ implementation but it's currently not possible in the add-on implementation.
* The main reason I never created a PR for the whole feature was that I only barely had time to work on the feature itself and would have been overwhelmed if I had to fix all bugs the feature introduced. And I also didn't want to put that burden on the other developers which don't even know the implementation of the feature yet.

Unfortunately due to family matters (own house, small daughter) I don't have any time for coding in my (non-existing) free time anymore. I would probably be able to support someone in understanding the architecture etc. but right now there is no real documentation Undecided


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

(2019-09-16, 22:38)Montellese Wrote: family matters (own house, small daughter)

Congratulations. Big Grin


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

Thank You. Blush


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

I managed to find some time to
  • rebase the media_import branch to almost current master (Python 2 --> 3 migration excluded)* extend the mediaimporter.emby python add-on to support
    • proper user authentication
    • dynamic setting callbacks
  • fix some bugs in the media import add-on API
I did NOT have time to test the original UPnP importer but since nothing changed in the general media import implementation it should still work ™.
I also noticed a problem that arises when opening the settings of an add-on based media provider / import while the add-on is importing items in the background.

Here's are the available test builds if anyone is daring enough to give them a try:


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

Hi,

https://github.com/Montellese/xbmc/tree/media_import_rebase_20191003/addons/mediaimporter.emby

Is this the current version of the emby plugin? Isn't there suppose to be a settings.xml file in the plugin directory. The configure button is ghosted for the plugin.

Cheers,
LongMan


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

I was able to enter my credentials, and the server showed that the user has been authenticated.
I was able to browse and add content type, but not individual libraries.
At startup a message appears, "Retrieving media items from server...." however, no item are retrieved.
If synchronize is chosen from the context menu of the media import, "Web-PDB debugger is active 100%.." is shown.
IIRC, the previuos windows builds had a pdb files with them.

Cheers


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

(2019-10-18, 03:02)LongMan Wrote: Hi,

https://github.com/Montellese/xbmc/tree/media_import_rebase_20191003/addons/mediaimporter.emby

Is this the current version of the emby plugin? Isn't there suppose to be a settings.xml file in the plugin directory. The configure button is ghosted for the plugin.

Cheers,
LongMan
There are currently no add-on wide settings. All settings are media provider and media import specific. So the add-on first has to detect a running Emby server which is then added as a media provider. You can then configure that media provider with your credentials. For that media provider you can then choose which media types to import which results in media imports. Each media import again has some custom settings like choosing which library view to use (or just use all of them) during the import.


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

(2019-10-18, 03:29)LongMan Wrote: I was able to enter my credentials, and the server showed that the user has been authenticated.
I was able to browse and add content type, but not individual libraries.
At startup a message appears, "Retrieving media items from server...." however, no item are retrieved.
If synchronize is chosen from the context menu of the media import, "Web-PDB debugger is active 100%.." is shown.
IIRC, the previuos windows builds had a pdb files with them.

Cheers
Ah looks like you got one step further.
  1. Your Emby server was detected as a media provider.
  2. You were able to configure it with your credentials.
  3. You were able to configure a media import.
    • On the settings of the media import you should be able to choose all or specific library views to import. Is that what you mean with "individual libraries"?
Looks like I forgot to remove the debug entry points I added to the add-on to test certain things. This results in the debugger stopping at a specific point in the python code and you would have to manually open the debugger and tell it to continue. I have fixed the version in git at https://github.com/Montellese/xbmc/tree/media_import_rebase_20191003/addons/mediaimporter.emby or you can download it as a ZIP from https://www.dropbox.com/s/qr58iadjfeer1va/mediaimporter.emby.zip?dl=1.

Please let me know if that fixes the synchronisation for you. Otherwise please provide the Kodi log file.

Thanks for the feedback.


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

Yes views are referred as libraries in the user interface.
On the import dialog, it has All, Choose for each content type. However, it does not allow browsing when "Choose" is selected

https://drive.google.com/file/d/1nhamulNyhgdLR-foEn2E6fL8Nesjzz8B/view?usp=sharing

It didn't solve the syncing. The pdb error went away.

Thanks for continuing to work on this.

Cheers


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

Thanks for the log. It looks like it can't retrieve the list of library views from your Emby server. It tries the following URL: http://<IP>:<Port>/Views. But it gets a HTTP 404 (Not Found). Maybe something works differently on my Emby server installation than on yours? TBH I have no idea how to use Emby. I simply installed it, configured a user and added a Movies and TV shows library. The rest is more or less reverse engineering in combination with the information from the Emby wiki on Github.

But reading the docs it looks like it should be http://<IP>:<Port>/Users/<User ID>/Views. I'll have to check when I'm home how / why it works there.


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

I just checked the code again and the fact that your URL is http://<IP>:<Port>/Views and not http://<IP>:<Port>/Users/<User ID>/Views indicates that your user authentication did not work / succeed. Did you enter your username and password manually or did you choose a username from the list and just enter the password.

I'm assuming that something is not working in general as to how to access your Emby server over the API. Therefore I've added debug log messages to every HTTP API call in the add-on. Please try again with https://www.dropbox.com/s/qr58iadjfeer1va/mediaimporter.emby.zip?dl=1.


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

Montellese, I assume that you are also using Emby server, 4.2.1.0.

BTW that user does not have a password.


RE: Media importing and library integration (UPnP, Emby, ...) - sualfred - 2019-10-18

@Montellese 
If you are interested and need any assistance in how Emby or the existing Emby-for-Kodi add-on works I can invite you to our internal Discord group with @angelblue05. She dealt with the API the last years and know all good and bad sides of it. I would love to see this feature be completed on some day. And I also think that Luke (of Emby) is interested in get this thing working. Just send me a PM in that case.

Edit:
Tested it with the latest Emby beta server (4.3.0.15) and it "worked". Tried a movie lib import, but it imported everything as movie. Music, TV shows, episodes, etc. No metadata at all except name + artwork.
FYI https://paste.kodi.tv


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

(2019-10-18, 16:42)LongMan Wrote: Montellese, I assume that you are also using Emby server, 4.2.1.0.

BTW that user does not have a password.

Yes I'm on the latest version but I have Emby server running on the same machine as Kodi so my HTTP API address starts with: http://localhost:8096/. But in the version I posted above I added "/emby/" to the base URL. Maybe that solve the problem for you. At least Emby's Swagger uses URLs with paths starting with "/emby/".


This forum uses Lukasz Tkacz MyBB addons.