Jump to content

Emby breaking JSON request


mellomade

Recommended Posts

mellomade

Hi All,

 

This is a related issue to the one illustrated HERE via local path settings.  The issue that remains is that Emby somehow breaks some of the player reporting via JSON. 

 

My iOS remote uses the following functions to return playback information to the GUI of my remote:

 

Player.GetItem - includes items such as thumbnail, title, genre, year, etc. - this is what breaks.  But only for the title, genre and year - thumb is queried fine (but I suspect this is cached locally as fallback).

 

Player.GetProperties - includes playback info such as total time, playback position, etc. - this seems to work fine.

 

I can replicate this in the following way:

 

On a fresh install of OpenELEC (15 RC2) I install the Emby stable addon and update the configuration to include my network login, set paths to local and enter server IP and user.  Then sync begins.

 

Once the sync is complete I restart and then go to 'Movies' from the home screen.  I try to start a movie from my iOS list that gets reported via JSON.  Everything works great initlally - all information is reported as it should.  If I then stop the movie and go find it in the list within Kodi and start playback again - items from the Player.GetItem function do not get reported (title, genre, year).

 

From then on that particular title ceases to report title, genre and year to the JSON-RPC command that requests it.  For good.  Regardless of where I try to initiate playback.  Other movies will break in the exact same way if I follow that sequence.

 

The only way I can reset this is to completely reinstall OpenELEC - even a resync of the db does not fix this once it has occurred.

 

I have included a log with Info selected in Emby and the Kodi log set to debug with JSON commands recorded so you can see what is being called when.

 

http://www.xbmclogs.com/pejtfalss

 

Sorry to keep bugging you guys with this but this causes a major problem with my automation system that is keeping me from using Emby full time in Kodi.  And I really want to use it because it is making metadata management and updating multiple clients a breeze vs. mySQL.

 

Thank you!

Link to comment
Share on other sites

Angelblue05

Hi mellomade,

 

Is it possible to let us know in your log the timestamp where you tried to play the item and it works, and when you tried to play and it stopped working? Thanks. 

 

This is an issue that will take a bit to fix, I think. Please bear with us :)

 

Thanks!

Link to comment
Share on other sites

mellomade

@@Angelblue05

 

Right around line 800 (10:52:48) is where the JSON request for the movie initiates and playback begins shortly after.  This first event (of 2) is where we try to play movie from the iOS remote and it works fine.  This file is stopped around 10:53:09.

 

The second event begins on line 1311 (10:53:19) where we used the keyboard to navigate to the same movie and play it back.  This is when the data is no longer reported.

 

To try and make things easier - I troubleshooted a little more using a web browser and the following command in the URL (which is the same command the remote uses to query the currently playing item).

 

http://<your-ip>:<your-port>/jsonrpc?request={ jsonrpc : 2.0 , id :1, method : Player.GetItem , params :{ playerid :1, properties :[ album , albumid , artist , artistid , disc , episode , fanart , genre , genreid , season , setid , showtitle , streamdetails , thumbnail , title , track , tvshowid , year ]}}

 

Then I ran the sequence again with a different movie (X-Men) and observed the output.  When you first playback the movie from the iOS command - you get this (which has all the relevant data intact):

 

{"id":1,"jsonrpc":"2.0","result":{"item":{"album":"","artist":[],"episode":-1,"fanart":"image://http%3a%2f%2f10.0.1.11%3a8096%2fmediabrowser%2fItems%2f21269c78fe8bad32389d9c2c56c7c620%2fImages%2fBackdrop%2f0%3fMaxWidth%3d10000%26MaxHeight%3d10000%26Format%3doriginal%26Tag%3de3ab56fe27d389446754d0fb04910a34/","genre":["Action","Adventure","Sci-Fi"],"id":8,"label":"X-Men","season":-1,"setid":0,"showtitle":"","streamdetails":{"audio":[{"channels":6,"codec":"dca","language":"eng"}],"subtitle":[],"video":[{"aspect":2.3499999046325683594,"codec":"h264","duration":0,"height":816,"stereomode":"","width":1920}]},"thumbnail":"image://http%3a%2f%2f10.0.1.11%3a8096%2fmediabrowser%2fItems%2f21269c78fe8bad32389d9c2c56c7c620%2fImages%2fPrimary%2f0%3fMaxWidth%3d10000%26MaxHeight%3d10000%26Format%3doriginal%26Tag%3da03b4d301f7d22c8f426d94d08990142/","title":"X-Men","track":-1,"tvshowid":-1,"type":"movie","year":2000}}}

 

When you then stop the first playback and use the keyboard to navigate to Movies and try to play it back from there you get this:

{"id":1,"jsonrpc":"2.0","result":{"item":{"album":"","artist":[],"episode":-1,"fanart":"image://http%3a%2f%2f10.0.1.11%3a8096%2fmediabrowser%2fItems%2f21269c78fe8bad32389d9c2c56c7c620%2fImages%2fBackdrop%2f0%3fMaxWidth%3d10000%26MaxHeight%3d10000%26Format%3doriginal%26Tag%3de3ab56fe27d389446754d0fb04910a34/","genre":[],"label":"X-Men","season":-1,"setid":-1,"showtitle":"","streamdetails":{"audio":[{"channels":6,"codec":"dtshd_ma","language":"eng"}],"subtitle":[{"language":"eng"}],"video":[{"aspect":2.3529410362243652344,"codec":"h264","duration":6260,"height":816,"stereomode":"","width":1920}]},"thumbnail":"image://http%3a%2f%2f10.0.1.11%3a8096%2fmediabrowser%2fItems%2f21269c78fe8bad32389d9c2c56c7c620%2fImages%2fPrimary%2f0%3fMaxWidth%3d10000%26MaxHeight%3d10000%26Format%3doriginal%26Tag%3da03b4d301f7d22c8f426d94d08990142/","title":"","track":-1,"tvshowid":-1,"type":"unknown","year":0}}}

 

You can see that the title, year, type and genre information are blank after that initial playback - which is exactly what my iOS remote is reporting.

 

Now if I restart OpenELEC and try to play that same file back from either method (iOS or from Kodi directly) I get this:

 

{"id":1,"jsonrpc":"2.0","result":{"item":{"album":"","artist":[],"episode":-1,"fanart":"","genre":[],"label":"X-Men","season":-1,"setid":-1,"showtitle":"","streamdetails":{"audio":[{"channels":6,"codec":"dtshd_ma","language":"eng"}],"subtitle":[{"language":"eng"}],"video":[{"aspect":2.3529410362243652344,"codec":"h264","duration":6260,"height":816,"stereomode":"","width":1920}]},"thumbnail":"","title":"","track":-1,"tvshowid":-1,"type":"unknown","year":0}}}
 

It seems like the metadata is progessively being corrupted somehow.  Maybe something is happening to the metadata after playback is stopped and emby resyncs?  It is strange because all the same metadata reports in the Kodi GUI just fine.

 

Anyway I hope this helps a bit more.

Edited by mellomade
  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...
mellomade

Sorry for the bump on this issue but I just wanted to check in to see if there is anything I can do to help.

Link to comment
Share on other sites

Angelblue05

@@mellomade

 

Remind me again, you are using direct paths or plugin paths? Stable or beta?

 

I've been looking into it when I have time, but still can't find the explanation. What I'm thinking is if you are using plugin paths, we redirect the path and this gets added to the database with no link back to the artwork or details. Maybe when it does a json rpc call with the new path (instead of the plugin path) it just can't find anything. This is one theory. If you are using direct paths, then I'm not sure...but rest assure, I'm always looking into it because it's an unsolvable puzzle so far! ;)

Link to comment
Share on other sites

mellomade

I have been using direct paths because the plugin pathway would not allow us to start playback from the home screen.  I tried both the stable and beta with the same results.

 

If using direct paths - is there a need to write back to the database for anything other than playcount and watched updates?  Static items like title, genre etc should be fixed I would think - as the JSON-RPC should only query data that exists and data like title, etc should only be updated via sync with the server, correct?

Link to comment
Share on other sites

  • 3 weeks later...
im85288

Any ideas about this? :)

Have you tried looking into the local Kodi videos database (use SQLite) before and after this takes place? The only logical explanation I can think off is somehow those fields are being wiped out after initial playback. Inspecting your database may confirm this and if that's the case it points at a "sync" issue with the addon triggered using the method your using to initiate playback.

Link to comment
Share on other sites

mellomade

Thanks @@im85288

 

The only thing I have been able to find searching table and data differences with a before and after database are the following:

 

In the 'Files' table there is an extra entry added for the specific movie I attempted playback for (Avatar) today.  There are also additional entries for 'About Time', 'All is Lost' and 'The A-Team' - each of which I have tried to test this with at earlier dates.  Each of these movies shows the problem illustrated above.

 

Here is the 'before' database info highlighted for the additional entries (there should only be 466 entries as I have 466 movies in the db):

 

55e4ce6796a6e_Before.jpg

 

Here is the database immediately after I tried to play 'Avatar':

 

55e4cf6cdbf31_After.jpg

 

I hope this helps!

Link to comment
Share on other sites

im85288

What would be more interesting to see is if the genre is missing after you initiate playback, I'm not at my pc at the moment to tell you the exact table this info is in but I can assure you it's in there somewhere...I think the table is genrelinkmovie. The JSON API merely queries what is in your database so something seems to be wiping that data out.

Link to comment
Share on other sites

mellomade

There are also the same additional entries in the 'path' table.

 

Here the 'strContent' and 'strScraper' are set to NULL rather than 'movies' and 'metadata.local' respectively.

Edited by mellomade
Link to comment
Share on other sites

im85288

Possibly, but looking at your screenshots unless I'm missing something they look identical except the second one starts one position down compared to the first (ie index 462).

 

Edit - i re-read what you were saying..that may be the issue..it's difficult to tell to be honest.

Edited by im85288
Link to comment
Share on other sites

mellomade

Entry 474 in the last image shows the Avatar movie - which is the difference between the before/after images.

 

Also - the genre_link table has an entry 'media_type' - which is set to 'movie' for all genre ids.  In the path table for those additional entries (467-474) the strContent is set to NULL and all other entries are set to 'movie'.

 

Edit - that was wrong - unrelated sorry.

Edited by mellomade
Link to comment
Share on other sites

mellomade

OK - interesting twist.

 

If I delete those extra entries in the database and write the new database back to Kodi it works again.

 

Somehow those entries that are written to the database (files, path) are causing this issue.

Link to comment
Share on other sites

im85288

Ok so the next step is to find out why they are being generated when you start playback via the Json API...I can't think of any reason why it would mess up your db and actually use it in my next up addon for initiating playback without any of these side effects.

 

I'm off now as sleep is needed but hopefully this helps in narrowing down the cause.

Link to comment
Share on other sites

mellomade

Server: Version 3.0.5721.25408 dev

Emby for Kodi: 1.1.35 beta

 

I did some more testing this morning - this time NOT using any JSON commands and just starting and stopping the movie using a keyboard to navigate and initiate playback.  Same results - so the JSON API has nothing to do with it (as expected as it is only querying the db).

 

It seems that whenever playback of a movie is stopped the database is being updated with additional full entries to the 'file' and 'path' tables - essentially duplicating the entry for the movie(s) played and not updating/overwriting the existing entries.  From what I can tell the only data being updated in that process is 'lastPlayed' - as the new entry has the most up-to-date information while the old entry is not updated.

 

And if I delete the duplicate entry created by Emby and copy the new database back to Kodi - any JSON query will work fine - until I try to play/stop it and play it back again.

 

Maybe somehow when this new entry is created it breaks a link between the emby table and kodi file and it confuses the feedback via JSON?

Link to comment
Share on other sites

im85288

Out of interest can you try and set the addon settings to use direct paths (a compete resync will be needed)

 

If that works then we know it's something to do with the plugin paths

Link to comment
Share on other sites

mellomade

I did originally at the very beginning of this thread - but switched because the plugin path would not allow playback via JSON command from the home screen (direct paths did solve that).

 

I can try reseting my db with direct paths disabled if you think that would help?

Link to comment
Share on other sites

mellomade

OK - so I tried disabling direct paths and resetting the db.  Same issue.

 

Interestingly though in 'file' and 'path' tables for this entry that gets created - it writes the smb path directly rather than the plugin path. 

 

So rather than:  plugin://plugin.video.emby/movies/9436ec5a74bf9a33ce627cf16d776a4e/?filename=Avatar (2009).mkv&id=9436ec5a74bf9a33ce627cf16d776a4e&mode=play

 

it writes: Avatar (2009).mkv

 

to the strFilename in the files table.

 

In the 'paths' table instead of plugin://plugin.video.emby/movies/9436ec5a74bf9a33ce627cf16d776a4e/

 

it writes the entire SMB path to the my MKV for that movie.

Link to comment
Share on other sites

mellomade

OK dudes - I think I have narrowed down the root of this issue.  It looks like there is a glitch in how the plugin is using Network Username and Password. 

 

If I leave these blank in the plugin settings and enter the network credentials manually to Kodi's passwords.xml then everything works as it should and the 'files' and 'path' records are updated rather than new records being added - and more importantly my JSON feedback works!

 

If I set up the plugin with username and password then there is a new entry to both 'files' and 'path' reflecting the entered username and password.  The initial scan shows a particular path entry like this:

 

smb://User Name:password@10.0.1.11/Movies/Avatar (2009)/

 

After playback there is a duplicate but it looks like this:

 

smb://User%20Name:password@10.0.1.11/Movies/Avatar (2009)/

 

Note the %20 rather than the space in the pre-synced entry.  I think this is the glitch.

 

Let me know if I'm barking up the right/wrong tree.

  • Like 1
Link to comment
Share on other sites

xnappo

This is quite strange.  When we add to the database, it will be the *actual* username and password.  I don't know how/why it would get replaced with the placeholders differently.  Maybe we shouldn't be trying to add the real username/password at all and should just put 'User%20Name:password' ...

 

Want to experiment?  Lines 124-132 of resources/lib/PlayUtils.py. 

Link to comment
Share on other sites

mellomade

It just has something to do with that space in the user name.  I actually went back and changed the user name on my server to be a single string and then entered those credentials into the Emby plugin (no entry into passwords.xml for Kodi) and everything works as it should.  File and paths entries are updated as they should be.

 

Just to keep in line with the Kodi folks you might want to consider (if possible) writing the credentials to the passwords.xml rather than appending every entry in the videos database for that.  I don't know what that would entail but I would have to think that the less Emby deviated from Kodi's way of doing things the better in the long run.

  • Like 1
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...