Jump to content

What endpoint to update a user's watched position?


adampalmer

Recommended Posts

adampalmer

I'm currently posting to: /emby/Sessions/Playing/Progress with data "{'PositionTicks': 7690000000, 'ItemId': '7778', 'EventName': 'timeupdate'}"

 

But this has 2 problems:

 

1- Emby takes this as the user actively watching that media

2- That positionticks isn't what gets stored in the database, but for some reason some value greater than that. 

 

Please advise!

Link to comment
Share on other sites

adampalmer

An update that  /emby/Users/$uid/PlayingItems/$item/Progress seems to have the same behaviour in that it shows the item as actively streaming. I don't want to do that - just update the last played position. 

Link to comment
Share on other sites

There is currently no API to do this. I guess it is something that has't been needed before. You can mark as played, unplayed, favorite, etc, but setting just the resume position is not possible. I suppose it's reasonable to add. What is the use case?

Link to comment
Share on other sites

adampalmer

Hey Luke,

 

I think I figured it out - I can actually make a DELETE request to "/emby/Users/" + auth_user['user_id'] + "/PlayingItems/" + item and even if the item isn't currently playing, I can update it's play position through that DELETE request without any further issues.

 

RE use case - my wife and I both have separate logins and watch our own stuff on our devices but have a few series and movies that we only watch together. I've written a script that will pull out every media ItemID in a defined playlist "Watching Together" and sync our individual accounts together with watched/unwatched/progress.

 

The script ended up a bit of a mess as it was a rushed job but seems to work well on a 10 minute cron and stands up to all the edge cases I threw at it. https://github.com/iodigitalsec/embystuff

 

Thanks for a great product, I just bought a lifetime licence. 

Link to comment
Share on other sites

  • 4 weeks later...
  • 1 month later...
LongMan

@@Luke,

 

Hopefully it's not too old to revive.

 

The Media Import project in Kodi is rolling again and an API endpoint to set resume position would be quite useful.

 

From Montellese, the developer

"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."

 

Any guidance here would be greatly appreciated.

 

Cheers.

Edited by LongMan
Link to comment
Share on other sites

LongMan

@@Luke, Thanks for replying. He fleshed out his request a bit more and pointed to the areas where his research suggest that he can get them done. I copied his requests below.

 

Here's what he wants 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/wik...-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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...
LongMan

@@Luke,

Didn't noticed before that you only spoke to one of the four points, the one using /PlayingItems. Am I to assume that the other 3 using /PlayedItems are ok and can be used as outlined. And further that the API extension would only be to accommodate resume point?

Or is it a new API end point to allow external clients to communicate with the server in all points?

 

Cheers

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...

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?

Link to comment
Share on other sites

LongMan

@@Luke,

 

Montellese's Response,

"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"

Edited by LongMan
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 3 weeks later...
LongMan

@@Luke,

 Just to update. Montellese has updated the addon to use the new API and it works for him on his test machine. Unfortunately, kodi is crashing on my system so I am waiting for the next build. I will post a link with the Kodi test build and the addon. Hopefully we can get some testers.

 

Cheers,

LongMan

Link to comment
Share on other sites

LongMan

Settings>Addons>Install from Zip file. (It should prompt to enable Unknown sources, enable it and go back to install the zip file, mediaimporter.emby.zip.)

There are no settings for the addon itself so there is nothing to configure there.

  • Settings>Media Sources>Media Providers>All Media Providers/Actice Media Providers (Either should work).  You should see your Emby Server here, sign in.
  • Go Back to Settings>Media Sources. Choose Media Imports>By Media Providers. You should see your Media types here.
  • Choose the type of media that you want to import. You call leave all to import all libraries of the media type, or select choose to select which libraries to import.

Importing should start as soon as you are finished.

 

Hopefully we can get a few testers

 

Thanks in advance,

LongMan

Link to comment
Share on other sites

LongMan

The benefits and pitfalls are going to differ based on one's vantage point, but here are my thoughts.

 

  • The biggest pro is that the addon will be the Official Kodi Repository.
    • Emby for Kodi writes directly to the database which is not sanctioned, and so it will never be allowed in the Kodi Repo.
    • Yes EmbyCon is there but that is a different approach.
  • Database changes will not adversely affect the addon because MediaImport would be a core function, and would have to considered and adapted whenever changes are made to the database.
    • As it is now, Emby for Kodi has a Decision tree to decide which database is present, and waits until beta before supporting a new version of Kodi. It's crazy to use alpha software, however, beacause of the way PR's to Kodi are handled, even released alpha versions, (not talking nightlys here) are fairly stable. And usually have some nice new features.
  • One is able to start watching as soon as an item has been synced, no need to wait for the sync to complete. Syncing is a background task.
    • Emby for Kodi bypasses the rules inside Kodi which has sanity checks for writing to the database. The official Kodi position is that it should use JSON but that would be much slower. As a result MediaImport, being constrained by these checks, would be slower but one does not have to wait, which I consider a good compromise.
    • I will admit that Emby for Kodi has gotten much better since @@Angelblue05 introduced syncing of individual libraries and resumption of incomplete syncs, two features that were not previously present in Emby for Kodi but were in MediaImport. To quote my Area Manager, "You should be looking to steal any good ideas that you come across". Good Jod Angelblue05
  • Another is that it is a new feature, a Greenfield. It will take center stage in Kodi when it is released and we all know that the one who is there first, or very early, is most likely to come out ahead. I suspect the Kodi user-base is larger than that of Emby.

 

There are other benefits to the user that are not necessarily a benefit to Emby.

  • For example, the ability to have more than one MediaImport Source.
    • That would facilitate Family/Friends sharing more seamlessly.
    • It also allows an admin to have a live redundant server.
    • This also allows your Netflix, Prime etc content to exist with your Emby content.
    • Many more possibilities are there.

 

The biggest con, there will be competition from other servers because it will be easier to write a plugin. There is also a Plex plugin being tested.

 

Thanks for taking the time to read this and for providing the API. I have been fiddling with Media Centers for a long while, since '06 or '07. I think this is a big leap forward.

 

Hopefully that helps.

 

Cheers,

LongMan

Edited by LongMan
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...