Author Topic: Options menu from python and force payload dictation to numbers  (Read 4047 times)

0 Members and 3 Guests are viewing this topic.

Hellow

  • Contributor
  • ***
  • Posts: 50
  • Karma: 0
    • View Profile
Options menu from python and force payload dictation to numbers
« on: November 11, 2013, 02:33:50 PM »
I'm trying to add support for sickbeard, atm im working on how i can add a tv show.

I have 2 questions:

1. It there are way to force vox/wsr to only use numbers instead of one, two .. ? I need to use it with a payload dictation. ex Dr. Who (1995)

2. I use sickbeards api to find a show, however since there are 10000's of shows on tvdb i get more then one hits. http://sickbeard.com/api/#sbsearchtvdb and i need the corrects show's tvdbid in order to add a new show.

Is there are way i can call a options meny (like xbmc has) from python? If it is can i have a example?

Thanks
Hellow

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Options menu from python and force payload dictation to numbers
« Reply #1 on: November 11, 2013, 03:59:20 PM »
1) Not really.  You could use a payload range, but you should be conservative with it and only use a range of numbers you would actually use such as 1980-2013 since it will create a list of items, with one for each value in the range.  Since not all shows use a year in the title you can either use an optional payload and then use logic to do different things depending on the number of payloads you get or you can create two commands, one with a year payload and one without.

Then again if you get #2 working then you probably don't really need this right?

Another option would be to use the payloadXML from XBMC (instead of dictation) if you only want to be able to add shows that you have in your XBMC library, but you probably want more flexibility than that.

2) You should be able to do this with a little fancy footwork and the OSD.ShowText command.  You can get a list of possible shows and store them (possibly as matches) and then display the list and let the user select an option with a command like "select show number {1}" and then use the payload {1} to read which match to use.  You could also use python but I don't think you really need to.
« Last Edit: November 11, 2013, 04:04:15 PM by jitterjames »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Options menu from python and force payload dictation to numbers
« Reply #2 on: November 11, 2013, 04:32:28 PM »
This will give you a starting point I think, for #2

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<commandGroup open="True" name="sickbeard" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="201" name="sick beard add show" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Scrape</cmdType>
      <cmdString>http://localhost:8081/api/e8d7c85b6ed1c920717fe2bab92a9e05/?cmd=sb.searchtvdb&amp;name={1}&amp;lang=en</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>System.SetClipboardText</cmdType>
      <cmdString>{LastResult}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <cmdString>"name":."(.*?)"</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)==(B)</ifType>
      <ifParams>{#M}&amp;&amp;1</ifParams>
      <then>
        <action>
          <cmdType>OSD.ShowText</cmdType>
          <cmdString>One match found... OK to add show here... using match 1</cmdString>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Results.RegEx</cmdType>
          <cmdString>"tvdbid":.(\d*)</cmdString>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>OSD.AddText</cmdType>
          <cmdString>adding ID {Match.1}</cmdString>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>OSD.ShowText</cmdType>
          <cmdString>You can say: "Add show number (X)"{CR}&amp;&amp;8000&amp;&amp;-5</cmdString>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>OSD.AddText</cmdType>
          <cmdString>({i}) - {Match.{i}}</cmdString>
          <cmdRepeat>{#M}</cmdRepeat>
        </action>
      </else>
    </if>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <cmdString>"tvdbid":.(\d*)</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>sick beard add show</phrase>
    <payloadDictation>payloadDictation: Regular</payloadDictation>
  </command>
  <command id="216" name="add show number" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <cmdString>Adding show with TVDBID: {Match.{1}}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>add show number</phrase>
    <payloadRange>1,16</payloadRange>
  </command>
</commandGroup>

Hellow

  • Contributor
  • ***
  • Posts: 50
  • Karma: 0
    • View Profile
Re: Options menu from python and force payload dictation to numbers
« Reply #3 on: November 11, 2013, 04:55:41 PM »
1) Not really.  You could use a payload range, but you should be conservative with it and only use a range of numbers you would actually use such as 1980-2013 since it will create a list of items, with one for each value in the range.  Since not all shows use a year in the title you can either use an optional payload and then use logic to do different things depending on the number of payloads you get or you can create two commands, one with a year payload and one without.

Then again if you get #2 working then you probably don't really need this right?

Another option would be to use the payloadXML from XBMC (instead of dictation) if you only want to be able to add shows that you have in your XBMC library, but you probably want more flexibility than that.



2) You should be able to do this with a little fancy footwork and the OSD.ShowText command.  You can get a list of possible shows and store them (possibly as matches) and then display the list and let the user select an option with a command like "select show number {1}" and then use the payload {1} to read which match to use.  You could also use python but I don't think you really need to.

I would like to get them, both.. :P is i can add shows directly without using the list.
The possible matches is returned as a string atm. I have been taking a look at the python wiki, but i cant understand it. Any chance you can explain the part with str,object,i tried to find some more info in the but i couldnt find any.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Options menu from python and force payload dictation to numbers
« Reply #4 on: November 11, 2013, 06:21:35 PM »
I think James's VC-only code above is probably what you want. (I don't know if you noticed it when you posted your last message or whether you were both posting simultaneously?)

That said, it's kind of hard to answer your question about Python, because it really depends on what you have in mind. If you mean that in VC you have already created a command that is returning a list of show matches (as strings) from sickbeard, and you want to do something with that in Python, it is basically along the lines of:

Code: [Select]
sickShows = vc.getObject("matches","")
for show in sickShows:
vc.callAction('TTS.SpeakSync',show, None)

In the above you're iterating through your list of matches, and telling VC to speak each one aloud sequentially. Obviously that is not what you will want to do with the list; this is just a basic example.

... I don't know if that makes any more sense than the existing documentation, but we do what we can.  :biglaugh
« Last Edit: November 11, 2013, 06:24:08 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)

Hellow

  • Contributor
  • ***
  • Posts: 50
  • Karma: 0
    • View Profile
Re: Options menu from python and force payload dictation to numbers
« Reply #5 on: November 11, 2013, 07:03:16 PM »
I think James's VC-only code above is probably what you want. (I don't know if you noticed it when you posted your last message or whether you were both posting simultaneously?)

That said, it's kind of hard to answer your question about Python, because it really depends on what you have in mind. If you mean that in VC you have already created a command that is returning a list of show matches (as strings) from sickbeard, and you want to do something with that in Python, it is basically along the lines of:

Code: [Select]
sickShows = vc.getObject("matches","")
for show in sickShows:
vc.callAction('TTS.SpeakSync',show, None)
In the above you're iterating through your list of matches, and telling VC to speak each one aloud sequentially. Obviously that is not what you will want to do with the list; this is just a basic example.

... I don't know if that makes any more sense than the existing documentation, but we do what we can.  :biglaugh

Thanks for the tip, but im just using .join to make whole string, then execute it after the loop is done. But your solution work aswell.

This part is the one i wanted more info about;
Code: [Select]
strObject
Valid values for strObject are:
"lastresult": returns String
"matches": returns List<"string">
"displaylanguage": returns String
"payloads": returns List<String>
"fpayloads": returns List<String>
strSubObject
At the moment, no objects make use of the strSubObject parameter

I saw james solution, i might go that way, im making code the works in python and when i add it, there is always something that dont work that i have to fix. Eg will not loop over a list with only object in. Really simple things. Edit come to think about it it might be .join() it dosnt like. I need to check it out before i give up :P
« Last Edit: November 11, 2013, 07:17:21 PM by Hellow »