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)



Media importing and library integration (UPnP, Emby, ...) - angelblue05 - 2019-11-15

I’m around and following this thread. I’ll try to help if I can. If you have questions about how Emby for Kodi does some stuff.


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

(2019-11-15, 02:14)LongMan Wrote: @Montellese

From Luke

"If you had one endpoint to update all of that at the same time, would you do that, or would you still be updating different values at different times?"

Edit:
That
being
  • watched: this seems to be possible with a call to POST /Users/{UserId}/PlayedItems/{itemId} with the property "DatePlayed" set properly
  • unwatched: this seems to be possible with a call to DELETE /Users/{UserId}/PlayedItems/{itemId}. I'm assuming that this also removes the "DatePlayed" property
  • date played: see watched / unwatched. The only "problem" here is that in Kodi it's possible to manually mark an item as unwatched but keep the "last played" property set
  • resume point: this seems to be possible with a call to DELETE ​/Users​/{UserId}​/PlayingItems​/{Id}
 

Whenever an item has changed I check if one of the properties listed above has changed compared to the information provided by the Emby server. Depending on which of the properties has changed I'm currently using different methods to push those differences / changes to the Emby server. If there would be a single endpoint that would make things easier because I would only have to execute a single API call instead of separate ones.


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

In the mean time I've fixed one of the open issues for sure and the other one most likely (a bit difficult to reproduce). I've started a new test build at https://jenkins.kodi.tv/view/Windows/job/WIN-64/11086/. It should be available on the mirrors at http://mirrors.kodi.tv/test-builds/windows/win64/KodiSetup-20191116-2dcd7450-media_import_rebase_20191003-x64.exe shortly.

This test build contains support for
  • manually adding a media provider by enter its URL
  • automatically observing changes to imported media imports on the Emby server and synchronizing them to the Kodi library
  • updating mark as watched / unwatched and resume point on the Emby server
  • improvements to the architecture / implementation

ATTENTION: There were changes to the video database layout so remember to drop your MyVideos117.db before testing this new build.


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

I tried the new build but i am not getting the server to show under media sources. The items in the database previously still plays but it doesn't update the server.

This is playing items that were in the database before
https://drive.google.com/file/d/12G_zbVxGEGM1dfWI7xJE3NqS3TMd_7MN/view?usp=sharing

This log is when I first installed without updating the plugin. Not sure why it crashed so i aatached the log
https://drive.google.com/file/d/1Q6MbYNFVq60AOFtgZiK4WMyrsD5Urk2W/view?usp=sharing

Hope that helps.

When you are comfortable with the Kodi Build, could you ask @Milhouse to run a LibreELEC build. It is much easier to test with LibreELEC as it is easily isolated, and is it also easier to set up multiple clients.


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

@LongMan thanks for the feedback. I forgot to mention that I made changes to the video database layout but I didn't bump the version. So you need drop the MyVideos117.db database for everything to work.


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

Does the Base URI include the Port?

https://drive.google.com/file/d/19FR9A7XH-boBX8vebHGM2tpsq69uBsqY/view?usp=sharing


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

(2019-11-17, 23:04)LongMan Wrote: Does the Base URI include the Port?

https://drive.google.com/file/d/19FR9A7XH-boBX8vebHGM2tpsq69uBsqY/view?usp=sharing

Yes the port is part of the base URI. Please try again with https://www.dropbox.com/s/qr58iadjfeer1va/mediaimporter.emby.zip?dl=1 and enable debug logging for Kodi. Did you try to add the media provider manually? IIRC in your case it should work with auto discovery.


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

Yes. Auto discoery does work but it crashes as soon as I select the user.

https://drive.google.com/file/d/10oI8AdmN9VDsbk7IAvIfSJS49M0Fdsil/view?usp=sharing


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

@Montellese,

From Luke,
"OK so in the 4.3 release you'll have this:
/Users/{UserId}/Items/{ItemId}/UserData
Which takes four params:
  • PlayCount
  • Played
  • PlaybackPositionTicks
  • LastPlayedDate
Please let me know if you have any questions. Thanks."


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

(2019-11-18, 01:53)LongMan Wrote: Yes. Auto discoery does work but it crashes as soon as I select the user.

https://drive.google.com/file/d/10oI8AdmN9VDsbk7IAvIfSJS49M0Fdsil/view?usp=sharing

That's odd. I don't see any crashes anymore on my setup but there used to be some due to deadlocks. Unfortunately I wasn't able to load your crash dump. For some reason it can't show the call stacks which makes it useless. Maybe I'm just out of practice Undecided

Enabling debug logging would help because right now there's almost no information in your log file.


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

(2019-11-20, 12:37)LongMan Wrote: @Montellese,

From Luke,
"OK so in the 4.3 release you'll have this:
/Users/{UserId}/Items/{ItemId}/UserData
Which takes four params:
  • PlayCount
  • Played
  • PlaybackPositionTicks
  • LastPlayedDate
Please let me know if you have any questions. Thanks." 

Great thanks. Any estimate for when 4.3 will be available? I'll add the code to detect / check the Emby server version and then we'll see if it works :-)


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

When I enable debug logging, it does not crash. It allows me to select the user and to add imports. However no synchronization takes place.
The logs are here.

https://drive.google.com/file/d/1I5-45MioYwGFBgPDRDaHnvZCG1QBotOY/view?usp=sharing

The New API is in the latest Beta of Emby Server, found Here. Choose Beta Channel

Cheers


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

(2019-11-20, 19:29)LongMan Wrote: When I enable debug logging, it does not crash. It allows me to select the user and to add imports. However no synchronization takes place.
The logs are here.

https://drive.google.com/file/d/1I5-45MioYwGFBgPDRDaHnvZCG1QBotOY/view?usp=sharing
That's an interesting hint concerning no crash with debug logging because I always have debug logging enabled. Can you disable debug logging and see if it starts to crash again?

The debug log indicates that your credentials are not correct. Maybe I should add a test button which allows to manually test if the entered credentials are correct or not.


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

If I disable debug logging again, it does not crash. Seems like it only crashes before first enabling it.

Emby Server is saying that TestSystem is authenticated. I provided the Emby logs here.


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

My apologies. It does crash with debug logging. Steps
  • Media Providers
  • All Providers or Active Providers (no difference)
  • EmbyServer
  • Select Manual
  • Select User (TestSystem in my case).
Kodi Crashes immediately.


Logs Here
https://drive.google.com/file/d/1HVisq1Jo6-thF8cM1xHbqtio6_MI8k-2/view?usp=sharing

NB. It does not crash if the user is typed in. (Which I had started doing)