Bug JSON-RPC, videodb: inconsistent return value for TvShow "watchedepisodes" property
#1
Bug 
Hi guys,

I'm working with the JSON-RPC and have found that I'm getting different results for the same tvshow, when using two different calls to the JSON-RPC.
Specifically, the watchedepisodes count is inconsistent.

Code:
Request 1:
{"jsonrpc": "2.0",  "id": 1, "method": "VideoLibrary.GetTVShows", "params": {"properties": ["episode","watchedepisodes"]}}

Return:
{
  id: 1,
  jsonrpc: "2.0"
  result: {
    limits: {
      end: 6
      ....
    tvshows: [6]
      ....
      2:  {
        episode: 1
        label: "Dexter"
        tvshowid: 2
        watchedepisodes: 1
        }
      ....

Request 2:
{"jsonrpc": "2.0",  "id": 1, "method": "VideoLibrary.GetTVShowDetails", "params": {"tvshowid": 2, "properties": ["episode","watchedepisodes"]}}

Result:
{
  id: 1
  jsonrpc: "2.0"
  result: {
    tvshowdetails: {
      episode: 1
      label: "Dexter"
      tvshowid: 2
      watchedepisodes: 0
    }
  }
}

As you can see, it's the same tvshowid, but I get different watchedepisodes counts.
Reply
#2
Looking over the code I can see what's going wrong. The json layer is looking in the FileItem for the info here:
https://github.com/xbmc/xbmc/blob/master...r.cpp#L172

Inside the videodatabase that property is set here (note that a CFileItem has to be passed in as item):
https://github.com/xbmc/xbmc/blob/master....cpp#L3504

However, the two JSON calls use different code paths, and the getTVShowDetails doesn't pass a CFileItem in, and creates an empty CFileItem for the result:
https://github.com/xbmc/xbmc/blob/master...y.cpp#L213

GetTvShows is returned a set of fileitems.

I suspect the fix is to either change the file item handler to use the video tag info, or update the Database API to allow the passing of a file item for that api.
Reply
#3
A fix to the file item handler would probably look like:
https://github.com/cg110/xbmc/commit/c25...0e5205ba40

@Montellese do you want a PR for this?
Reply
#4
Thanks for looking into this, didn't have the time yet. I commented on your code and would welcome a PR.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#5
I've updated it based on your comments, and put it in a separate branch:
https://github.com/cg110/xbmc/commit/a5d...b033bb6549

If you could take another look at it, I'll submit a PR once I've had to time test it actually fixes this issue (my analysis of the problem says it should do, but I like to double check things)
Reply
#6
*sigh* and while it fixes the cause of not getting the result back, it doesn't fix the problem Sad

Actually stepping through the code, it appears that m_playCount gets changed into a true/false for if all the episodes have been watched.

Looks like the only way to properly extract the details is an api change to videolibrary to also pass in a fileitem for updating at the same time as the videoinfotag.

I'll look at doing the api change in the next couple of days.
Reply
#7
Hi guys,

Just wanted to comment briefly - thanks so much for the quick responses and attempts to solve this issue!
I myself have no cpp skills whatsoever unfortunately, so can't offer any solid code changes... but I'm happy to see that other people also care and want to see this codebase constantly improving.

Keep is up Smile
Reply
#8
So I now have a fix:
https://github.com/cg110/xbmc/commit/a7d...50ceb821b1

which works (which is kinda important Smile :
Code:
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "tvshowdetails": {
      "episode": 85,
      "label": "'Allo 'Allo!",
      "tvshowid": 86,
      "watchedepisodes": 12
    }
  }
}

@Montellese if you could take another look, if you're happy I'll raise a PR for this.

Note I've gone for the simplest fix, so it could be pulled into gotham, I think the longer term "right" thing would be to extend the videoinfotag to provide the info, rather than having the data in 2 different structures.
Reply
#9
Feel free to post a PR but I can't guarantee you that it will be accepted because we are very close to the first Gotham release candidate.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#10
Just for reference, in case anyone else wants the fix, the PR is:
https://github.com/xbmc/xbmc/pull/4561
Reply
#11
@Montellese,
How can I find out if/when this fix made it into Gotham?
Reply
#12
You will see it in the PR4561. As long as it's "Open" it hasn't been merged.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply

Logout Mark Read Team Forum Stats Members Help
JSON-RPC, videodb: inconsistent return value for TvShow "watchedepisodes" property0