Jump to content

Websocket message


Angelblue05

Recommended Posts

Angelblue05

@@Luke, @@ebr

 

I'm trying to learn working with the Websocket, because I had a couple of ideas I wanted to do. I'm a bit stumped with the information received. From my understanding the "Key" is an Id created just for that specific user. I could not figure out how to query via the API using the "Key" to return information I could actually use. After testing, I'm out of ideas so I'm asking the following:

 

Is there any chance to change the key value returned to the actual item "Id"? My reasoning behind it is this: The websocket message already provides the UserId, why return a Key only reserved for that User? We already know which user the change happens to. With the way it is currently, I don't see how it can be useful for clients to have the Key over the item "Id" to work with. Am I missing something?

 

For example: Let's say the movie Into the Woods was marked as watched. The key returned is "224141". If the key was the actual Id "2331a7efc178166cc02e053e4d6df9ab", then it would allow clients to use the API /Users/{UserId}/Items/{Id} if they wanted to do something with the information. Or else, allow API query using the UserData Key. I hope it makes sense. Thanks for your time!

{"MessageType":"UserDataChanged","Data":{"UserId":"6a9cb6714653c32997a4ef3d56a13743","UserDataList":[{"PlaybackPositionTicks":0,"PlayCount":1,"IsFavorite":false,"LastPlayedDate":"2015-03-12T23:05:01.5096525Z","Played":true,"Key":"224141"},{"PlayedPercentage":89.0533277425042,"UnplayedItemCount":30,"PlaybackPositionTicks":0,"PlayCount":0,"IsFavorite":false,"Played":false,"Key":"d5b58e1a-8cd9-6e7e-8df6-f6aa7125a60d"}]}}

550aa4e147621_api_movieid.jpg

Edited by Angelblue05
Link to comment
Share on other sites

I haven't messed with that particular message much but I've found the ones I do use have the relevant information.

 

The "key" you are looking at there is the key to the user data which is going to be some sort of global identifier like tmdb/IMDb ID.

  • Like 1
Link to comment
Share on other sites

Angelblue05

I see! So it is connected. I thought I was missing something. I just could not figure it out. Thanks!

Edited by Angelblue05
Link to comment
Share on other sites

multiple items can share the same user data, so it is key based. the UserData object will have a key property. the events will report on the key, so you could use that to match them up.

Link to comment
Share on other sites

Angelblue05

The biggest problem is that Kodi doesn't have a "custom" field in their database for a random key to filter from. We basically have one field which we are using for the item Id (only way to work with the API). Using the key seems counter intuitive since we can't even query the server using the Key value. :) But I understand what you are saying. It's just maybe we'll have to go a different route since we won't be able to use the given information. 

Edited by Angelblue05
Link to comment
Share on other sites

Angelblue05

If the key has dashes it means there's no IMDB or TMDB ID. It just used the actual Item Id with dashes. ^ At least, that's what I figured after checking results in the API.

Edited by Angelblue05
Link to comment
Share on other sites

Angelblue05

Exactly, the only way to make use of the websocket is that with the initial import or in the update, we get the UserData Key and insert it. We could use C17 for Movies, C18 for shows to contain the key information. It would be much simpler if the itemId was returned (from a client's perspective)

 

http://kodi.wiki/view/Databases#Views_2

Edited by Angelblue05
Link to comment
Share on other sites

Angelblue05

For the past day, I've been trying using swagger-ui, but have been unsuccessful, hence the "flaw" in this situation. Hopefully, @@Luke will consider modifying this.  ^_^

 

Option 1: Return the itemId instead of the current key. It doesn't have to change anything server side, but client side, we'd at least be able to know which item changed.

Option 2: If there isn't currently, add a way to query the HTTP API using the current UserData key. This would allow clients who don't import the UserData Key to refer back to it in a query to the server.

 

Let me know if you figure something out, I'm still looking for a possible solution. :)

Link to comment
Share on other sites

I would prefer not to have to track and maintain user Key to Item Id mappings.

Is there any way to query MBS items based on user key?

 

They should already be there.  Each item has a user data object attached to it.  Within that user data object is the user data key.

 

There is not necessarily a 1:1 realationship between itemId and user data key.  That is why there isn't an item ID delivered.  If there were, it would have to be a list of item ids.

Link to comment
Share on other sites

we could always make an endpoint for that. how are you going to handle changes that occur while kodi isn't open?

  • Like 1
Link to comment
Share on other sites

Yea this is the price we've paid for bundling do much data onto the library items. Because what does last modified mean? The item, the user data, what about changes from other items that affected inherited images. Then what about administrative settings that affect the way items are presented to users. So there's just a lot to think about there and that will take time. But the other question of querying by a user data key is fine

Link to comment
Share on other sites

  • 2 weeks later...

we base it on external provider ids. so for example, two videos with the same imdb id will share the same user data key

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