Jump to content

Welcome, Guest!

Be a part of CinemaVision today! Once registered and logged in, you will have access to public chat and your own private messenger, you can view and contribute guides, collaborate on the forums, review downloads, give reputation to your fellow members, contribute content and so much more. Registering is quick and completely free, so what are you waiting for?
   Sign In    Sign Up

Become a RedCarpet Club Member Today!

   Join Now
shredder

Kodi JsonRPC commands via powershell

Recommended Posts

I am trying to launch a movie sequence directly based on the movieid, but i cannot seem to figure out how to pass the params in a powershell format to cinemavision. I have it most of the way there, but the documentation is just not clear enough on how to send a movie id. If i can send a movie id and launch the sequence, cinemavision should know what to do from there as i have CV set to pick a sequence based on the movie genre. the code below, only seems to launch the editor, how do i launch a movie?

 

$data = @{
    'jsonrpc' = '2.0'
    'method' = 'Addons.ExecuteAddon'
    'id' = 1
    params = @{
        addonid = 'script.cinemavision'
        params = @(
           'experience'
        )
       
    }
   
}
 
$json = $data | ConvertTo-Json -Depth 100
 
$url = 'http://'+$hostname+':'+$port+'/jsonrpc'
$mycreds = New-Object System.Management.Automation.PSCredential ($username, $secpwd)
$webreq = Invoke-WebRequest -Uri $url -Credential $mycreds -Body $json  -ContentType application/json -Method POST -AllowUnencryptedAuthentication

Share this post


Link to post
Share on other sites

in typical fashion, I figure this out 10 minutes after i post for help. 
I've spent days/weeks/months/hours trying to achieve this and i finally have. I'll share to spare anyone else the headache of having to go through this. My ultimate purpose for this is to integrate this in home assistant via script. 

Script Outline: This script is designed to parse through ALL movies that have not been watched (playcount less than 1) , of the list of movies that have not been watched, a random movie is selected and the movie ID is stored into a variable to then pass to the cinemavision api call. 

Assumptions: You will need to have mapped your sequences based on genre type so Kodi already knows which sequence to play when a movie ID is passed to it. If the script fails to play a movie, it means that no sequence (again, based on genre) has been mapped for that type of movie. 

What you need to do: in the username password and host name variables, you will need to provide the sign on that you would typically use for logging on to the web interface for Kodi for each call, there are 2 calls. 

#Returns a list movie and movie ID
#required param ID
$username ='username'
$pwd = 'password'
$hostname = 'ipaddress'
$port = '8080'
$secpwd = ConvertTo-SecureString $pwd -AsPlainText -Force
$data = @{
    'jsonrpc' = '2.0'
    'method' = 'VideoLibrary.GetMovies'
    'id' = 1
    params = @{
        properties = @(
            'genre',
            'playcount',
            'runtime'
        )
        filter = @{
            field = 'playcount'
            operator = 'lessthan'
            value = '1'
        }
    }
}
 
$json = $data | ConvertTo-Json -Depth 100
 
$url = 'http://'+$hostname+':'+$port+'/jsonrpc'
$mycreds = New-Object System.Management.Automation.PSCredential ($username, $secpwd)
$webreq = Invoke-WebRequest -Uri $url -Credential $mycreds -Body $json  -ContentType application/json -Method POST -AllowUnencryptedAuthentication
$webreq
$unwatchedfulllist = ($webreq.content|convertfrom-json).result.movies|get-random
$pickedmovie = $unwatchedfulllist.movieid
 
#Returns a list movie and movie ID
#required param ID
$username ='username'
$pwd = 'password'
$hostname = 'ipaddress'
$port = '8080'
$secpwd = ConvertTo-SecureString $pwd -AsPlainText -Force
$data = @{
    'jsonrpc' = '2.0'
    'method' = 'Addons.ExecuteAddon'
    'id' = 1
    params = @{
        addonid = 'script.cinemavision'
        params = @{movieid = "$pickedmovie"}
 
    }
}
$json = $data | ConvertTo-Json -Depth 100
 
$url = 'http://'+$hostname+':'+$port+'/jsonrpc'
$mycreds = New-Object System.Management.Automation.PSCredential ($username, $secpwd)
Invoke-WebRequest -Uri $url -Credential $mycreds -Body $json  -ContentType application/json -Method POST -AllowUnencryptedAuthentication

 

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Guidelines and Terms of Use.