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, ...) - Montellese - 2019-10-18

(2019-10-18, 19:09)sualfred Wrote: @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
Thanks for the offer.

The main thing I don't know how to get working is updating metadata on the Emby server from the add-on i.e. if the user has watched a movie from the Emby server in Kodi how to tell Emby that the item has been watched etc. Apart from that I only ran into an odd behaviour of the "SortName" property for seasons which I don't understand but everything else seems to be working fine (at least with my setup).

Unfortunately your pastebin doesn't point to a specific kodi log.


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

@Montellese 

Sry, picked wrong file:
https://we.tl/t-qar6Qg4N8J (too big for paste.kodi.tv) (edit2: i hope it's the correct one. I'm on my way to bed but I'm happy to retry it tomorrow for a new one)

With the addon we receive server notifications. And we have a server plugin https://github.com/MediaBrowser/plugin.video.emby/wiki/kodi-companion . Emby is informing its clients about new media, changed library data, etc. Dunno if this or an small notification listener is an option for you.

@angelblue05 can tell you everything.

Edit:
https://github.com/MediaBrowser/Emby.Kodi.SyncQueue/tree/master/Emby.Kodi.SyncQueue


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

Not sure if it helps but this is a database from a Emby for Kodi machine. https://drive.google.com/file/d/10syd9a9y4JXwGaTHoWA8qR7rfusvlsVD/view?usp=sharing


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

(2019-10-18, 22:59)sualfred Wrote: @Montellese 

Sry, picked wrong file:
https://we.tl/t-qar6Qg4N8J (too big for paste.kodi.tv) (edit2: i hope it's the correct one. I'm on my way to bed but I'm happy to retry it tomorrow for a new one)
Thanks. It looks like in your setup Kodi detected your Emby server as a UPnP server and tried to import media items over UPnP. I've only ever tested this import mechanism between two Kodi instances. The other approach @LongMan is testing uses the mediaimport.emby add-on which in turn uses Emby's HTTP API.
(2019-10-18, 22:59)sualfred Wrote: With the addon we receive server notifications. And we have a server plugin https://github.com/MediaBrowser/plugin.video.emby/wiki/kodi-companion . Emby is informing its clients about new media, changed library data, etc. Dunno if this or an small notification listener is an option for you.

@angelblue05 can tell you everything.

Edit:
https://github.com/MediaBrowser/Emby.Kodi.SyncQueue/tree/master/Emby.Kodi.SyncQueue
I had this fully implemented and integrated in the C++ based Emby importer. But IMO the approach using "hard coded" C++ media imports is not future proof because then the importers are bound to Kodi core and to its release cycle. Therefore I'm working on re-writing the same functionality as an add-on. But I have not had the time to also cover observing existing media imports for "live" changes.


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

How do I test the addon approach? It's enabled but nothing is happening.


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

(2019-10-19, 07:44)sualfred Wrote: How do I test the addon approach? It's enabled but nothing is happening.

Whenever I start Kodi I get the following log messages from the mediaimporter.emby add-on:
Code:
[mediaimporter.emby] Emby Media Importer started
[mediaimporter.emby] Looking for Emby servers...
...
[mediaimporter.emby] Emby server "Emby (DEVCOMPUTER)" (ac2a47435c994abaa366f542f3f0fef6) successfully added and activated
After that my Emby server "Emby (DEVCOMPUTER)" is available as an active media provider and any connected media imports are automatically synchronized.


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

@Montellese,

Could the situation be that you have a token on your Dev machine and one is not being generated by the addon?
@sualfred Is an Access token also required now? IIRC, there were changes when Emby went from ver 3 to ver 4.


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

@Montellese 
Ah, that's why. For some reasons the auto discovery of my Emby server does not work here. Never found out the issue and I have to manually add the connection details in Emby for Kodi or EmbyCon. 

@LongMan 
They changed the login method in v4, yes. Emby for Kodi and EmbyCon are handling it differently.

Let me quote a reply of @null_pointer to the question "Just wondering why embycon needs to authenticate on each start and emby for kodi does not."
Quote:It is because of the access token that the Emby server uses to authenticate requests.

A client authenticates using the username and password and the server returns an access token that is then used in requests.
This access token can also be stored and used in later requests.
If the client stores the access token in some sort of persistent storage mechanism then it can use the access token next session without having to re-authenticate the user.
If the access token is not stored in persistent storage then the client will need to re authenticate each session.

E4K and EmbyCon use different approaches for this.
EmbyCon does not store the access token between client sessions and re authenticates each time a user starts Kodi or a user is changed with fast user switching.



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

@LongMan at first I was using a fixed API key in the add-on because it was the easiest way of authentication. But now the add-on first uses the /Users/Public endpoint to retrieve all (public) users on the Emby server. This endpoint should be always accessible. It results in the list of available users in the media provider settings dialog. If that doesn't work for you I'm missing something essential. I then uses the username / userid and password from the media provider settings dialog and tries to authenticate. The received access token is not stored persistently which results in the add-on authenticating itself to the Emby server on every import / synchronization.

Did you try the second version of the add-on I uploaded? Since it contains logging for every HTTP API call to the Emby server the Kodi debug log might provide some additional insight on the issue.

@sualfred ah good to know. Looks like it would be good to be able to manually configure a media provider instead of fully relying on automatically discovering them. I will see what I can do about that.


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

The new log is here.
https://drive.google.com/file/d/1lAalTADhA04Bx0H9uwNpbQcQu1Mw2c6r/view?usp=sharing

It does show the users. Normally I hide all the users and enter them manually. However, I made the user visible in the last log file to test that. The user does show but still no synchronization.

Cheers


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

@Montellese 

Emby has a security feature that always hides the users on unknown networks (if you have a remote connection for example). And, like LongMan is using it, it's possible to disable the user selection completely and only allow manual login. It's also possible to hide just single users from the login screen to avoid brute-forcing etc.

I suggest you to add a generic connection / credential setting and drop the automatic connection discovery completely. Just because it's easier and everyone who is running a setup like this is able and experienced enough to add those things by hand.


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

@LongMan now it looks like your user authentication settings are wrong because it can neither find a user id (if you select one of the automatically detected users) nor a username (if you manually enter one).
I also just noticed that I've added the new log messages as DEBUG logs but you don't have debug logging enabled which is why they are not in the logs.

@sualfred
  • It already is possible to manually enter username and password. But you can also choose from a list of detected users and just enter the matching password manually. I don't see why I should drop this convenience.
  • The original reason I started with the media importing was because people found it too difficult / complicated to manually setup normal media sources. One advantage of the current media importing is that potential providers are automatically discovered. So I will not drop this functionality. But I'll look into adding the possibility to manually configure providers.



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

Success. Strange when I enabled Debug and rechoose the userid it started synchronizing. It is still running but I grabbed the logs..

https://drive.google.com/file/d/1lAalTADhA04Bx0H9uwNpbQcQu1Mw2c6r/view?usp=sharing

The resume feature seems to work. I played 'Muscle Shoals' and it resumed at the correct time. I let it run them stopped it. Start it again, and it resumed at the new point.
Also it let me choose the views/libraries now. Will test further when it is finishes the sync.


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

@LongMan it was probably solved by adding the "/emby/" to the beginning of the path of the URLs used by the add-on to call Emby's HTTP APi.

It looks like the log files you provided are identical with the last ones. Maybe you got the wrong ones. They're also not debug logs.


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

Sorry, here you go
https://drive.google.com/file/d/1uv4-rp8hJy6LggSm-gymC5bSAaUO-qB3/view?usp=sharing


This forum uses Lukasz Tkacz MyBB addons.