Author Topic: Question in regards to optional payloads  (Read 2958 times)

0 Members and 1 Guest are viewing this topic.

DexDeadly

  • Jr. Member
  • **
  • Posts: 27
  • Karma: 3
    • View Profile
Question in regards to optional payloads
« on: August 01, 2016, 06:09:11 PM »
Hello guys,

So I'm using a program called MoviePosterApp, not sure if anyones heard of it but it basically runs through movie posters in your library or from TheMovieDB to show upcoming movies.  www.movieposterapp.com if you want to check it out. 

Anyway it uses basic http commands so I've gone ahead and have actually made a few different options for displaying different movie posters by name using voxcommando.  I"ll have a video of me doing this soon.  However I've come across a tricky one that I'm a little stumped on and looking for some ideas on how to make this work.  Here is my current command that I've created.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.2.0-->
<commandGroup open="True" name="Show Times" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="132" name="Add Showtime" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <if ifBlockDisabled="False" ifNot="True">
      <ifType>(A)&lt;(B)</ifType>
      <ifParams>{5}&amp;&amp;</ifParams>
      <then>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>op1</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>op1</param>
            <param>{5}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <if ifBlockDisabled="False" ifNot="True">
      <ifType>(A)&lt;(B)</ifType>
      <ifParams>{6}&amp;&amp;</ifParams>
      <then>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>op2</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>Results.SetVar</cmdType>
          <params>
            <param>op2</param>
            <param>{6}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <action>
      <cmdType>Scrape</cmdType>
      <params>
        <param>http://captainamerica:8082/showtimes.html?addShowtime({1},{2}%20{3}%20{4}%20{var.op1}%20{var.op2})</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>add poster showtime</phrase>
    <phrase optional="true">for</phrase>
    <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">XbmcPayloads\xbmcIMDB.xml</payloadFromXML>
    <payloadList>Tonight,Tomorrow,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday</payloadList>
    <payloadList optional="true">at</payloadList>
    <payloadRange>1,24</payloadRange>
    <payloadList optional="true">:15,:30,:45</payloadList>
    <payloadList>AM,PM</payloadList>
  </command>
</commandGroup>

I tried a few different ways of just passing the payload directly over in the command but the information wasn't passing along.  I've found that if I structure it this way I can get it to post almost 100% correct. Except when you don't use the option variables it tries to send stuff along that makes it break a bit.  Is there a way that if the variable isn't used that it just skips it?  Let me know if I am not explaining this correctly. 
« Last Edit: August 02, 2016, 03:06:16 PM by jitterjames »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Question in regards to optional payloads
« Reply #1 on: August 01, 2016, 06:45:44 PM »
When you say "option variables" I guess you mean "optional payloads".

Using optional payloads can be a bit tricky, but in your case you probably could use the variable {#P} in a logic block to do different things depending on the number of payloads.

There appeared to be something wrong with your xml. I think it's because you put extra spaces (blank lines) at the beginning and end of the code block.
« Last Edit: August 01, 2016, 07:09:39 PM by jitterjames »

DexDeadly

  • Jr. Member
  • **
  • Posts: 27
  • Karma: 3
    • View Profile
Re: Question in regards to optional payloads
« Reply #2 on: August 01, 2016, 06:56:27 PM »
Thanks JitterJames,

I'll give this a test and try it tonight.  I have a folder with all my others, I just moved this outside of it since it was something I was working on.  Helps me know what was finished and whats not.  I did mean payloads :).  I'll let you know what happens.
« Last Edit: August 01, 2016, 07:09:47 PM by jitterjames »

DexDeadly

  • Jr. Member
  • **
  • Posts: 27
  • Karma: 3
    • View Profile
Re: Question in regards to optional payloads
« Reply #3 on: August 02, 2016, 02:16:31 PM »
Hello JitterJames,

I ended up making one of my optional payloads required, the word at, and then using the {#P} I compared it to either 5 or 6 giving it the correct string now to the program.  I wish I had a little more control over how to send but the application gets kind of weird if I send just a string, plus instead of 2PM it'll send over two PM.  The structured layout works better to keep it simple.  I"ll post a video and my command tree for anyone interested.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Question in regards to optional payloads
« Reply #4 on: August 02, 2016, 03:17:36 PM »
Hello JitterJames,

I ended up making one of my optional payloads required, the word at, ...

I agree that "at" should not be optional since it is unnatural to say this command without saying "at", but there is no reason why "at" should be a payload.  You should use a phrase for it.

I wish I had a little more control over how to send but the application gets kind of weird if I send just a string, plus instead of 2PM it'll send over two PM.  The structured layout works better to keep it simple.  I"ll post a video and my command tree for anyone interested.

I don't understand any of this part. "more control how to send", "The application", "it", "it'll", "gets kind of weird" etc.  none of that has a precise meaning to me.  "The structure layout works better" than what?

Anyway sounds like you are on track.  If you need help with any specific questions please let me know.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Question in regards to optional payloads
« Reply #5 on: August 02, 2016, 03:27:00 PM »
I wish I had a little more control over how to send but the application gets kind of weird if I send just a string, plus instead of 2PM it'll send over two PM.

Your "two PM" description sparked a memory. I don't know whether this is what you're referring to, but if you were trying to use a dictation payload and you were having problems with how the time was interpreted, the solution I provided here might be of interest: http://voxcommando.com/forum/index.php?topic=1948.0

« Last Edit: August 02, 2016, 06:32:09 PM 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)

DexDeadly

  • Jr. Member
  • **
  • Posts: 27
  • Karma: 3
    • View Profile
Re: Question in regards to optional payloads
« Reply #6 on: August 02, 2016, 07:35:12 PM »
nime5ster,

I will have to give this a try but yes when saying the number I got the word.  This may actually allow me to use a full dictation as a payload.  Though I don't think so, it resolves my two > 2 issue. I just would need to replace the spaces with %20 as well.

JitterJames,

I've adjusted and changed it to a phrase and made it so it sends the @ symbol.  I like it better then showing the at.  As far as what I meant with what to send was that I couldn't use a payload dictation with out it sending the time as words not numbers.  Then when sending the scrape if would send actual spaces and not %20 which is an issue since it caused incomplete info sent to the server. Sometimes the application would interpret as a weird character then cause the application to crash.  I believe that's something he's addressed in the latest version of the software to help with weird characters. 

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Question in regards to optional payloads
« Reply #7 on: August 02, 2016, 08:34:32 PM »
You can use the VC action Tools.Encode.URI to translate spaces to %20.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.2.2-->
<command id="69" name="Encode my string" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Tools.Encode.URI</cmdType>
    <params>
      <param>où est-il allé?</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>{LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Encode my string</phrase>
</command>

... Or if you want to do it all in Python, you'll need to import urllib, e.g.:

Code: [Select]

import urllib

s = "hi there how are you?"

print urllib.quote(s)

« Last Edit: August 02, 2016, 08:46:25 PM 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)

DexDeadly

  • Jr. Member
  • **
  • Posts: 27
  • Karma: 3
    • View Profile
Re: Question in regards to optional payloads
« Reply #8 on: August 22, 2016, 02:50:46 AM »
Ahhh, well this Encode.URI could actually be very useful.  I'll have to give this a shot and toy around with it to see what I can come up with.