Jump to content

Item properties in the API


Angelblue05

Recommended Posts

Angelblue05

@@Luke

 

In reference to this thread: http://emby.media/community/index.php?/topic/28189-cant-connect-to-playon/&do=findComment&comment=272965

 

Maybe I'm being crazy here, but shouldn't there ALWAYS be a path key (at first level, not within mediasources), regardless if it's virtual or physical. The API doesn't say it's an optional key. Is the API just outdated?

 

Anything that's not marked as optional should always be present (fields is not the issue here), otherwise chaos follows. Then anarchy, then the end. Ok, I'm being dramatic, but can we fix this? I've based a lot of logic around if a key is optional or not... Now I'm getting worried that I will have to rewrite a lot of it, because the server doesn't behave as expected.

 

Edit: If it can't be fixed or whatever, it's no problem, but then the API should really be updated to reflect the proper behavior of the key.

Edited by Angelblue05
Link to comment
Share on other sites

Angelblue05

This is the url we use: {server}/mediabrowser/Users/{UserId}/Items/%s?format=json

 

Which is the one that only has field for userid and itemid, which should normally retrieve all possible keys, because it's only meant to return one item.

In the api, it's indicated as: Path (string),

Link to comment
Share on other sites

Angelblue05

Exactly, but in bluc's log, we get a key error for the path, because the key is missing. :/

18:56:06 T:4064   ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                             - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                            Error Type: <type 'exceptions.KeyError'>
                                            Error Contents: ('Path',)
                                            Traceback (most recent call last):
                                              File "C:\Users\blucm\AppData\Roaming\Kodi\addons\plugin.video.emby\default.py", line 125, in <module>
                                                Main()
                                              File "C:\Users\blucm\AppData\Roaming\Kodi\addons\plugin.video.emby\default.py", line 36, in __init__
                                                entrypoint.doPlayback(id)
                                              File "C:\Users\blucm\AppData\Roaming\Kodi\addons\plugin.video.emby\resources\lib\Entrypoint.py", line 28, in doPlayback
                                                item = PlaybackUtils().PLAY(result, setup="default")
                                              File "C:\Users\blucm\AppData\Roaming\Kodi\addons\plugin.video.emby\resources\lib\PlaybackUtils.py", line 49, in PLAY
                                                playurl = PlayUtils().getPlayUrl(server, id, result)
                                              File "C:\Users\blucm\AppData\Roaming\Kodi\addons\plugin.video.emby\resources\lib\PlayUtils.py", line 35, in getPlayUrl
                                                playurl = self.directStream(result, server, id)
                                              File "C:\Users\blucm\AppData\Roaming\Kodi\addons\plugin.video.emby\resources\lib\PlayUtils.py", line 147, in directStream
                                                if result['Path'].endswith('.strm'):
                                            KeyError: ('Path',)
                                            -->End of Python script error report<--
Link to comment
Share on other sites

The way the JSON creation works is that null items simply aren't in the json representation.  That's one of the advantages of JSON - it makes for much lighter payloads across the wire.

 

Therefore, you cannot assume that any property (other than ones that simply can never be null I guess) will always be in your result.

 

So, if the item doesn't have a Path (which could be the case if it were some sort of virtual item) the property simply won't exist in the JSON result you receive.

Link to comment
Share on other sites

Angelblue05

Ok. I guess strings are different than array, because they show up empty. I'm just surprised the path is missing, I was expecting for it to be there, regardless. Just like any other empty array. Thank you both for your time.

Edited by Angelblue05
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...