Author Topic: Pulling cast from a tv show or movie.  (Read 3802 times)

0 Members and 1 Guest are viewing this topic.

DexDeadly

  • Jr. Member
  • **
  • Posts: 27
  • Karma: 3
    • View Profile
Pulling cast from a tv show or movie.
« on: April 10, 2016, 03:21:52 AM »
I want to say I heard this work when I maybe first installed this but now it doesn't seem to work.  When I'm saying "What Movie is this" it states the movie then says staring and then nothing.  I thought it would say the 3 main stars of the movie / tv show.currently this is what it looks like. 



Now if I do a test in postman to see how the cast comes back it looks like the following:
http://10.1.1.70:8080/jsonrpc?request={"jsonrpc": "2.0", "method": "Player.GetItem","params":{"playerid":1,"properties":["cast"]}, "id": "VideoGetItem"}

information is returned as the following:
Code: [Select]
{
  "id": "VideoGetItem",
  "jsonrpc": "2.0",
  "result": {
    "item": {
      "cast": [
        {
          "name": "Jeremy Clarkson",
          "order": 1,
          "role": "himself",
          "thumbnail": "image://http%3a%2f%2f10.1.1.25%3a8096%2femby%2fItems%2f21c34fd934fe6d5bd8b286539b7f84d2%2fImages%2fPrimary%3fMaxWidth%3d400%26MaxHeight%3d400%26Index%3d0%26Tag%3d358f4d9b42d2568103ad79db8a3dddb4/"
        },
        {
          "name": "Jonathan Palmer",
          "order": 2,
          "role": "Himself",
          "thumbnail": "image://http%3a%2f%2f10.1.1.25%3a8096%2femby%2fItems%2f97da624e6b257227ddf03bf7f292d0d3%2fImages%2fPrimary%3fMaxWidth%3d400%26MaxHeight%3d400%26Index%3d0%26Tag%3da6ec76a7621a7dab137ff5426d34d884/"
        },
        {
          "name": "Russ Swift",
          "order": 3,
          "role": "Himself",
          "thumbnail": "image://http%3a%2f%2f10.1.1.25%3a8096%2femby%2fItems%2f312d155e42d314bd7c0b563a859eb655%2fImages%2fPrimary%3fMaxWidth%3d400%26MaxHeight%3d400%26Index%3d0%26Tag%3d31dcd3dd6134011a954ae409648923a2/"
        }
      ],
      "id": 46,
      "label": "Clarkson: No Limits",
      "type": "movie"
    }
  }
}

if I change {lastresult} to {item.cast} it'll start speaking everything there.  Is there anyway to parse just the name out when it is returned back so that I can just here the names and not it trying to read every single item between the cast brackets?  I've been programming so much in this thing giving me a lot of info from Kodi and it's been great. 

Any input would be greatly appreciated.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Pulling cast from a tv show or movie.
« Reply #1 on: April 10, 2016, 08:41:08 AM »
It looks like your version of the command was accidentally edited, and the most important action was removed.

In the default configuration that comes with VC, the command is:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.1.4-->
<command id="540" name="What movie is this" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>XJson.Raw</cmdType>
    <params>
      <param>Player.GetItem</param>
      <param>"playerid":1,  "properties": ["title","cast"]</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>"name".*?"(.*)"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.MatchConcat</cmdType>
    <params>
      <param>, </param>
      <param>3</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>XJson.ParseTokens</cmdType>
    <params>
      <param>Now playing {item.title} starring {lastresult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>XJson.SoftMute</cmdType>
    <params>
      <param>60</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTS.SpeakSync</cmdType>
    <params>
      <param>{LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>XJson.SoftUnMute</cmdType>
    <params />
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>What Movie is this</phrase>
</command>

The Results.RegEx line is required to capture the "name" json items from the result returned from Kodi.

In fact, if you roll over the line
Code: [Select]
XJson.Raw:Player.GetItem&&"playerid":1,  "properties": ["title","cast"]in your history window in VC, you'll see the same json result that you saw.

This is also captured in the VC log, if it's running. However, very recently Kodi has changed something on its end, which is causing a log jam in VC that we are trying to address for a future VC release.

So using the Vox Log to monitor Kodi behaviours is not advisable right now.

By the way, in general, we copy and paste commands from our command trees onto the forum, rather than using screen captures, as that makes it easier for others to test our commands if discussing a problem (or just use them if they're of interest).
http://voxcommando.com/mediawiki/index.php?title=XML_on_the_forum#Posting_Your_Code_to_the_Forum
« Last Edit: April 10, 2016, 08:58:26 AM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Pulling cast from a tv show or movie.
« Reply #2 on: April 10, 2016, 09:55:45 AM »
In this case, almost all of the actions are important! ;)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Pulling cast from a tv show or movie.
« Reply #3 on: April 10, 2016, 11:31:34 AM »
 :P
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

DexDeadly

  • Jr. Member
  • **
  • Posts: 27
  • Karma: 3
    • View Profile
Re: Pulling cast from a tv show or movie.
« Reply #4 on: April 10, 2016, 03:42:33 PM »
Hello,

Thanks for the information I'll give this a try.   I thought I might of but when I installed a new version on a different pc to compare it also did not have that line.   Not sure what that is about.   Anyway next time I'll go ahead and post the xml and apologize about that. Knowing about the RegExid a nice piece for future reference as well.  I showed this program off recently at a hackerspace meeting and what I've done with it.  Everyone was very impressed.  I've made a ton of new commands pulling multiple items from the player such as year premiered,  show name,  episode,  plot,  etc.  Thanks for the help I'll give this a try now.   
« Last Edit: April 10, 2016, 10:34:09 PM by DexDeadly »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Pulling cast from a tv show or movie.
« Reply #5 on: April 10, 2016, 04:31:21 PM »
You are right.  In the later versions of VC this action seems to be missing from the Kodi / Isengard configuration.  It is still present in the Kodi / Helix config though.

I'm not sure how it got deleted but thanks for letting us know.

DexDeadly

  • Jr. Member
  • **
  • Posts: 27
  • Karma: 3
    • View Profile
Re: Pulling cast from a tv show or movie.
« Reply #6 on: April 11, 2016, 04:37:31 PM »
Just wanted to report back that once I added this line I'm now getting back the starring cast.  No problem on reporting that to you.  I figured something was missing.  The by product of learning the command missing was RegEx I've now watched the RegEx videos posted and now have another new toy to play with and keep me up at night :).
« Last Edit: April 12, 2016, 03:44:03 PM by jitterjames »