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, ...) - sualfred - 2019-10-20

@Montellese 
Sorry, never got so far because my server isn't recognized and I thought there is no option for a manual input Smile


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

Small update
  •  Resume works properly on the same machine but it is not transmitted back to the server. The web client shows the old resume point. (Feels like you already knew that)
  • The dateadded seems to be different here. Recently added on Media Import is not showing the last items added. Actually it looks like all items has today's date for dateadded.
  • Tagging the items with the View/Library name works
  • Movies and Music Videos seem to sync ok. However, something has gone awry with tv shows. Episodes appears in the wrong show. (if desired i can attach databases from a media import sync and a Emby for Kodi sync)
Cheers

Edit: The tvshow is fine. It's the poster that is wrong in some cases. eg. The Putin Interviews has Mr Bean Animated Poster and Ku'Damn 56 has The Fix Podcast Poster. However, 60 minutes and DatelineSBS have their correct posters


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

(2019-10-20, 18:52)sualfred Wrote: @Montellese 
Sorry, never got so far because my server isn't recognized and I thought there is no option for a manual input Smile
There currently isn't but I've started working on it. It shouldn't be too difficult but there are a few edge cases that need to be covered. E.g. right now the whole system relies on the fact that a media provider is automatically detected and marked as active / inactive. For manually entered media providers this is not available so we either have to consider them as always active or we have to check periodically if they are still active / available or not.


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

(2019-10-20, 22:17)LongMan Wrote: Small update
  •  Resume works properly on the same machine but it is not transmitted back to the server. The web client shows the old resume point. (Feels like you already knew that)
  • The dateadded seems to be different here. Recently added on Media Import is not showing the last items added. Actually it looks like all items has today's date for dateadded.
  • Tagging the items with the View/Library name works
  • Movies and Music Videos seem to sync ok. However, something has gone awry with tv shows. Episodes appears in the wrong show. (if desired i can attach databases from a media import sync and a Emby for Kodi sync)
Cheers

Edit: The tvshow is fine. It's the poster that is wrong in some cases. eg. The Putin Interviews has Mr Bean Animated Poster and Ku'Damn 56 has The Fix Podcast Poster. However, 60 minutes and DatelineSBS have their correct posters 
Thanks for the detailed feedback.
  • Yes I'm aware that synchronizing the resume point and watched status back to the Emby server is currently not working properly. I haven't figured out how to do this properly yet.
  • dateadded is always a difficult topic in Kodi. I'll take a closer look.
  • I've also noticed (also for movies) that sometimes retrieving the poster from Emby fails but then when syncing again it suddenly works. So something is still not right there in the add-on code.



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

(2019-10-18, 22:31)Montellese Wrote: 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.
@sualfred
  • Can you or @angelblue05 shed some light on reporting to the server.
  • IIRC, Emby for Kodi was doing that until version 3 or 4. Why did the method used changed?
  • Is it still possible to do it this way? If not, how should playback be handled?

Cheers


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

(2019-10-21, 20:07)LongMan Wrote:
(2019-10-18, 22:31)Montellese Wrote: 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.
@sualfred
  • Can you or @angelblue05 shed some light on reporting to the server.
  • IIRC, Emby for Kodi was doing that until version 3 or 4. Why did the method used changed?
  • Is it still possible to do it this way? If not, how should playback be handled?

Cheers 
I found the following thread in the Emby developer sub-forum https://emby.media/community/index.php?/topic/75926-what-endpoint-to-update-a-users-watched-position/ which is exactly what I used in the initial C++ implementation of the Emby media importer. I also found a "POST /Items/{ItemId}" endpoint which seems to allow changing any property of an item. But I didn't manage to get it to work properly yet.

Maybe I'll try my luck with
  • POST /Users/{UserId}/PlayedItems/{Id} for marking an item as watched
  • DELETE /Users/{UserId}/PlayedItems/{Id} for marking an item as unwatched
  • DELETE ​/Users​/{UserId}​/PlayingItems​/{Id} for setting the resume point of an item



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

Keeping my fingers crossed. I left a post asking about an API endpoint to do it since Luke mentioned it.


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

(2019-10-22, 00:53)LongMan Wrote: Keeping my fingers crossed. I left a post asking about an API endpoint to do it since Luke mentioned it.
Thanks. Since I don't have an account in the Emby forum here's what I want to be able to update on the server for a video item:
  • 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}
I've also come across https://github.com/MediaBrowser/Emby/wiki/Playback-Check-ins and maybe it would make sense to extend the Emby Media Importer add-on to support this playback tracking for imported media items. But it still doesn't cover the cases where a user manually marks items as watched / unwatched on the Kodi library without actually playing the item.


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

I'm curious. In the addon we use addon callbacks. onNotification is returning information for this case. Isn't is possible to "monitor" those notifications by core for your case, too?

Code:
sender xbmc - method: VideoLibrary.OnUpdate  - data: {"item":{"id":13,"type":"movie"},"playcount":1}



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

(2019-10-23, 06:49)sualfred Wrote: I'm curious. In the addon we use addon callbacks. onNotification is returning information for this case. Isn't is possible to "monitor" those notifications by core for your case, too?

Code:
sender xbmc - method: VideoLibrary.OnUpdate  - data: {"item":{"id":13,"type":"movie"},"playcount":1}
In theory yes but then every media importer add-on would have to decide on its own whether it is responsible for sending these updates back to a specific server. But there might be multiple add-ons installed which could do this so we make this decision in Kodi and explicitly tell a specific add-on to do it.

But this doesn't change the fact that we need to have specific API methods in Emby server to perform these actions independent of how the add-on becomes aware of an update.


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

@Montellese

From Luke,
I would not use /PlayingItems because that's used to report playback stopped. While it might work as a hack, there will inevitably be side effects, such as various things listening for these events.
 
It would probably be best for me to give you a new api, and then you would just have to check the server version to see if it's supported or not.



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

From Luke

"Yea what you're doing for watched/unwatched is fine because we already have that function. That's what the toggle in our apps use. When you mark watched, you can optionally provide the date along with it to indicate when it was watched.
 
So the only thing you're missing is the ability to explicitly set the playback position."



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

@LongMan thanks for your support and for talking to the Emby guy(s).

In the meantime I've been busy with implementing
  • the possibility to manually add / lookup a media provider by adding it's URL
  • the possibility to provide smaller changesets for imported items at runtime. For the Emby media importer add-on this means that it uses a websocket to listen to library updates / changes published by the Emby server and then pushes these updates to Kodi without having to perform a full synchronization.
These two features are working but there are two issues I need to solve before I can provide another test build.


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

Thanks for the update.


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

@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}



This forum uses Lukasz Tkacz MyBB addons.