Author Topic: Launch Pandora via VoxCommando  (Read 10564 times)

0 Members and 2 Guests are viewing this topic.

HomieTheClown

  • Jr. Member
  • **
  • Posts: 42
  • Karma: 0
    • View Profile
Re: Launch Pandora via VoxCommando
« Reply #15 on: July 27, 2014, 01:47:03 PM »
Ty fellas!

Thank for responding so fast. I just figured it out finally after looking at one of your other post about downloading subtitles.  I'm using Frodo 12.2.  My problem was the "addonid" field.

After reading the post above I thought the "addonid" field was supposed to be filled in until I saw the download subtitles addon section.  Then I saw you simply left it alone so my param line read as follows
 

<param>Addon.ExecuteAddon</param>
<param>"addononid":"script.xbmc.pandora</param>

I got more questions about other functions, but I want to try to figure it out first before I waste your time. Afterall it's Sunday. :) Thanks again bud.
« Last Edit: July 27, 2014, 01:50:03 PM by HomieTheClown »

HomieTheClown

  • Jr. Member
  • **
  • Posts: 42
  • Karma: 0
    • View Profile
Re: Launch Pandora via VoxCommando
« Reply #16 on: July 27, 2014, 01:55:41 PM »
Hey

I had one more quick question regarding Pandora. Is there a way to tell VC to start one of your Pandora stations when you open it?

HomieTheClown

  • Jr. Member
  • **
  • Posts: 42
  • Karma: 0
    • View Profile
Re: Launch Pandora via VoxCommando
« Reply #17 on: July 27, 2014, 02:51:42 PM »
I managed to get it to work but I wanted to show what I did because I think it's kind of hokey how I did it.  Surely there's got to be a better way. (check out the photo)

I basically wanted to have P open up and start playing my 80's station so I put a bunch of up arrows and 1 second pauses to get it to work.  In the beginning I had to add a focus command to focus on the XBMC window or it wouldn't start moving up the station list. Is there a better way of doing this? 

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Launch Pandora via VoxCommando
« Reply #18 on: July 27, 2014, 03:34:19 PM »
Hey, if it works, it works. :)

Sometimes, keyboard emulation is the only way.

Ideally, the Pandora addon should allow us to pass it a parameter when we call it, but you would have to ask the developer of the addon about that. As far as we can tell, this addon doesn't accept any parameters, but who knows.

I did figure out another way, also hackish, but it works. James noticed that the addon has a setting where you can get it to automatically load the last station you played on launch. If you select it, then that station's ID is stored in the addon's user settings file.

It would be nice if we could adjust that setting using a json method, but nothing is jumping out in the documentation. However, I was able to create a command that changes the station by overwriting that settings.xml file, replacing the old station ID with a new one. Hackish, but it worked on my tests. Not sure how robust a solution it is.

A bigger problem, however, is getting the station IDs for all of your stations. Those IDs are the same numbers that you see when you're logged in on the Pandora website and choose one of your stations. If there is a Pandora page that lists all of your stations on one page, in theory you could scrape that to get all the IDs. I don't know much about the service, as I don't use it.

There's no obvious way to get that level of data from XBMC either. (I'm not saying it's impossible -- maybe on the XBMC forum can help you with that.)

But if you want to create your payload XML list manually (or at least create a small payloadXML file with a few of your favourite Pandora stations), here's the command that I used to change between my two stations. It requires an understanding of payloads that you mention you don't yet have.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.0.0.3-->
<command id="471" name="play Pandora station" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>XJson.Raw</cmdType>
    <params>
      <param>Addons.ExecuteAddon</param>
      <param>"addonid":"script.audio.pandora"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>File.Read</cmdType>
    <params>
      <param>C:\Users\[your user name]\AppData\Roaming\XBMC\userdata\addon_data\script.audio.pandora\settings.xml</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegExReplace</cmdType>
    <params>
      <param>"last_station_id".value="\d*"</param>
      <param>"last_station_id" value="{1}"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>File.Write</cmdType>
    <params>
      <param>C:\Users\[your user name]\AppData\Roaming\XBMC\userdata\addon_data\script.audio.pandora\settings.xml</param>
      <param>{LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>play pandora station</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">XbmcPayloads\pandora.xml</payloadFromXML>
</command>

You will need to:

1. Edit the file path to your own user path in the command. (In 2 of the command actions -- File.Read, and File.Write)
2. Enable the addon setting to "launch last station played" or whatever it says, in XBMC.
3. Create your own Pandora.xml payload xml file. That's the file that associates your radio station names with the IDs that XBMC needs in order to select the right station.

Start by copying and pasting my command into your tree. Save your tree, exit the command tree editor and then go back in ("Edit"). You'll get a message saying you're missing the payload xml file "pandora.xml". The command will be there, but the pandora.xml payload line will be red.

Double-click the red line, click "new/edit", and start creating your payload xml file. The radio station IDs are the "value", the radio station names or whatever are the "phrase". If you want to have different ways of asking for the same station, put commas between your phrases.

More on payloads:
Payloads: http://voxcommando.com/mediawiki/index.php?title=Payloads
Last section of: http://voxcommando.com/mediawiki/index.php?title=Logical_Command_Builder
« Last Edit: July 27, 2014, 04:21:50 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)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2012
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Launch Pandora via VoxCommando
« Reply #19 on: July 27, 2014, 03:44:41 PM »
Screen shot of possible use. Obviously you'll want to save the payload xml file that you've created before exiting the payload xml editor windows.
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: 7715
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Launch Pandora via VoxCommando
« Reply #20 on: July 27, 2014, 03:48:03 PM »
Nime5ter's method is better but if you still want to use keyboard emulation you can use either

XJson.Btn.KB
 or
XJson.Raw     Input.ExecuteAction

I doubt that you need a full second pause between keypresses, but you might still need a pause after opening pandora.

Try this.  It should open pandora and then press up 4 times.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.0.0.3-->
<command id="426" name="open pandora" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>XJson.Raw</cmdType>
    <params>
      <param>Addons.ExecuteAddon</param>
      <param>"addonid":"script.audio.pandora"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>XJson.Raw</cmdType>
    <params>
      <param>Input.ExecuteAction</param>
      <param>"action":"up"</param>
    </params>
    <cmdRepeat>4</cmdRepeat>
  </action>
  <phrase>open pandora</phrase>
</command>
« Last Edit: July 28, 2014, 02:11:54 PM by jitterjames »