Solved: GetMovieDetails - A little help on how to get this API call to work?
#1
Question 
Hello,

I'm almost certainly missing something basic and when someone clues me in, I'll no doubt smack myself on the forehead.

I wrote a python script many years ago which works with XBMC (prior to the rebrand to Kodi). The script used the GetMovieDetails API call and continued to work after the switch from XBMC to Kodi. At some point this stopped working (I can't recall exactly which version of Kodi) and I never really fixed it was only something I was working on and never completely finished, but figured it was time to. However I'm struggling to do so since the API has changed (again, I'm sure i'm overlooking the obvious, please be kind!).

Originally I used the following code (where movieID is the id of the movie in the SQL database i.e. 51)

Code:
xbmc_json_rpc_url = "http://username:password@localhost:8080/jsonrpc"

payload = {"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieDetails", "params": {"properties": ["mpaa","tagline"], "movieid": int(movieID)}, "id": "1"}
url_param = urllib.parse.urlencode({'request': json.dumps(payload)})

response = requests.get(xbmc_json_rpc_url + '?' + url_param, headers=headers)


Looking at http://kodi.wiki/view/JSON-RPC_API/v6#Vi...vieDetails, the JSON request body has changed since I last used it, but I can't figure out how to get it working again even in a basic form and was hoping for help.

On this page the schema is
Code:
{
  "params": [
    {
      "$ref": "Library.Id",
      "name": "movieid",
      "required": True
    },
    {
      "$ref": "Video.Fields.Movie",
      "name": "properties"
    }
  ],
  "description": "Retrieve details about a specific movie",
  "returns": {
    "properties": {
      "moviedetails": {
        "$ref": "Video.Details.Movie"
      }
    },
    "type": "object"
  }
}

It also mentioned the parameters are
Quote:
Library.Id movieid
[ Video.Fields.Movie properties ]


So for example if I wanted to obtain the details for a movie with an ID "51", I thought it would be the case that I need to create the following (where the Library.Id has been substituted for the movieID):

Code:
payload = {"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieDetails", \
            "params": [\
             {\
             "$ref": 51,\
             "name": "movieid",\
             "required": True
             },\
             {\
             "$ref": "Video.Fields.Movie",\
             "name":"properties"\
             }\
            ],\
            "description":"Retrieve the details about a specific movie",\
            "returns":{\
             "properties":{\
              "moviedetails":{\
               "$ref":"Video.Details.Movie"\
              }\
             },\
            "type":"object"\
            }\
            }

Using a logger object in python, this produces the json below, which is then used as a request body to http://username:password@localhost:8080/jsonrpc (as shown in the original code).

Code:
{
    "params": [
        {
            "name": "movieid",
            "$ref": 51,
            "required": true
        },
        {
            "name": "properties",
            "$ref": "Video.Fields.Movie"
        }
    ],
    "description": "Retrieve the details about a specific movie",
    "returns": {
        "type": "object",
        "properties": {
            "moviedetails": {
                "$ref": "Video.Details.Movie"
            }
        }
    },
    "jsonrpc": "2.0",
    "method": "VideoLibrary.GetMovieDetails"
}

When I do this, I only seem to get a hang up on the python script. No data or error codes being returned from Kodi or an indication of what's happening.

Could anyone shed any light on this?
Could anyone provide me with a basic GetMovieDetails example in case that helps?

Any help would be greatly appreciated. Thanks in advance!
Reply
#2
Found the solution. Nothing wrong with the original code! User error Sad
Reply
#3
(2016-11-15, 17:34)Psychobob Wrote: Could anyone provide me with a basic GetMovieDetails example in case that helps?

I use following python code, hope it helps....

Code:
# Get all the properties of the movie
JSON_req = {"jsonrpc": "2.0",
                    "method": "VideoLibrary.GetMovieDetails",
                    "params": {"movieid": 51,
                    "properties": ["art",
                                        "cast",
                                        "dateadded", "director",
                                        "fanart", "file",
                                        "genre",
                                        "imdbnumber",
                                        "lastplayed",
                                        "mpaa",
                                        "originaltitle",
                                        "playcount", "plot", "plotoutline", "premiered",
                                        "rating", "runtime", #"resume",
                                        "setid", "sorttitle", "streamdetails", "studio",
                                        "tagline", "thumbnail", "title", "trailer",
                                        "userrating",
                                        "votes",
                                        "writer"]},
                      "id": "1"}
log('JSON_req string = %s' % json.dumps(JSON_req))
JSON_result = utils.executeJSON(JSON_req)
log('JSON VideoLibrary.GetMovieDetails result = %s' % JSON_result)
Add-on : Bluray iso utils Rewrite of BR_iso_enhancements
Add-on : BR_iso_Enhancements Give theatrical & directors cut from the same bluray iso each their own library entry, use bluray iso's of tv shows as if they are already ripped.
Reply
#4
Thanks Wimpie, looks like you posted that just as I closed the thread. Appreciate the input but it looks like it was a case of user (my) error :S
Reply

Logout Mark Read Team Forum Stats Members Help
Solved: GetMovieDetails - A little help on how to get this API call to work?0