VoxCommando

VoxNastics (User Guides and Mods) => XML Exchange => Topic started by: jitterjames on July 16, 2013, 11:41:20 AM

Title: Internet Radio
Post by: jitterjames on July 16, 2013, 11:41:20 AM
Did you know that you can play internet audio streams with VoxCommando?

Here is a sample group that plays one of my favourite radio stations, "Radio Paradise".

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<commandGroup open="False" name="radio paradise" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="93" name="Stream Radio Paradise" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Sound.PlayStream</cmdType>
      <cmdString>http://www.radioparadise.com/m3u/mp3-128.m3u</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Stream Radio Paradise, start the stream</phrase>
  </command>
  <command id="87" name="what playing on radio paradise" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Scrape</cmdType>
      <cmdString> http://www.radioparadise.com/xml/chumby.xml</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <cmdString>&gt;(.+)&lt;</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <cmdString>This is {Match.5}, by {Match.4}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <cmdString>This is {Match.5}, by {Match.4}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>whats playing on radio paradise</phrase>
  </command>
  <command id="88" name="stop the stream" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Sound.StopStream</cmdType>
      <cmdString />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>stop the stream</phrase>
  </command>
</commandGroup>

This groups has 3 commands.
* One to start playing the stream (internet connection required of course)
* One to stop playing
* One to scrape "now playing" information from the Radio Paradise website.
Title: Re: Internet Radio
Post by: nime5ter on July 16, 2013, 01:12:56 PM
Cool, and seemingly simple, except for the tricksy regular expressions (RegEx) bit that you use to get the artist and song info from the Radio Paradise site. At least for the uninitiated.

It's nice that they provide that clean xml though!

So, if I may, I'm going to try here to dissect how your RegEx action works. As per VC's instructions, I used this RegEx cheat sheet as a guide: http://www.mikesdotnetting.com/Article/46/CSharp-Regular-Expressions-Cheat-Sheet.

First, in your command you scrape the whole page chumby.xml (which seems to provide metadata on the four most recent songs played/playing?).

Within the page that you've just scraped, in RegEx speak you are then looking for a particular pattern (.+), which must appear between the characters ">" and "<".  Because you're using Results.RegEx, it won't evaluate expressions across new lines -- that would require us to use the action Results.RegExSingle not Results.RegEx.

This means that:

1. It will look for the first instance of the character ">"
2. Whatever is in parentheses ( ) is what it will define as the pattern that we want to capture. So, it should find, capture, and continue to capture any subsequent characters after a ">" -- except if it encounters a newline character -- up until it encounters the next "<".
3. It will store everything between the > and < characters (as long as there are no newline characters, because RegEx looks for patterns line by line) as a match.

So, looking at an excerpt from the Radio Paradise chumby.xml page:

<?xml version='1.0' encoding='UTF-8'?>[new line here, so won't use this ">" but will keep looking for the next one]
<playlist>[new line here, so won't use this ">" but will keep looking for the next one, etc. throughout this scrape]
<refresh_time>1373990601</refresh_time> [Match.1]
  <song>[new line here, so won't use this]
    <playtime>8:59 am</playtime> [Match.2]
    <timestamp>1373990367</timestamp> [Match.3]
    <artist>Susie Suh</artist> [Match.4]
    <title>Feather In The Wind</title> [Match.5]
    <album>The Bakman Tapes</album> [Match.6]
    <songid>43357</songid> [Match.7]
    <rating>6.5</rating> [Match.8]
    <coverart>htp://www.radioparadise.com/graphics/covers/m/B006ONTX82.jpg</coverart> [Match.9]
  </song>

So, to announce that it is playing {song x} by {artist y}, we need
Code: [Select]
song = {Match.5} and artist = {Match.4}
Did I get that right?
Title: Re: Internet Radio
Post by: jitterjames on July 16, 2013, 01:40:23 PM
Absatively.  So if anyone wanted to include the album name too, they could use {Match.6}
Title: Re: Internet Radio
Post by: Kalle on July 16, 2013, 01:55:13 PM
Hi nime5ter - great explanation  :clap ::bow ::duh

So this is also very helpful for any other scrape command.

Thanks
Title: Re: Internet Radio
Post by: nime5ter on July 16, 2013, 02:35:23 PM
Hi nime5ter - great explanation  :clap ::bow ::duh

So this is also very helpful for any other scrape command.

You are very generous with your praise, thanks Kalle.  :biglaugh

By the way, I edited my post above to try to make a couple points more clear ... not sure if it helped.

It seems like a good idea to try to master this RegEx stuff in order to make the scrape action truly useful. But I suspect the Radio Paradise example is particularly simple; how many sites will have this nice clean xml code to scrape??

For example, I think it could be fun to ask Vox about movies currently playing in theatres -- what's playing at local cinemas tonight, at what times are particular movies playing.

Since IMDB provides this information (as does Google), it would be great if I could scrape their sites. But looking at the page source of one of those pages (e.g. http://www.imdb.com/showtimes/), I'm pretty sure I could never figure it out.

Bummer!
Title: Re: Internet Radio
Post by: Kalle on July 16, 2013, 02:53:01 PM
That is true, the most sites have a very confused code  :bonk , but I think a python script with "BeautifulSoup" can do this.

https://www.youtube.com/watch?v=Ap_DlSrT-iE (https://www.youtube.com/watch?v=Ap_DlSrT-iE)

http://www.crummy.com/software/BeautifulSoup/bs3/documentation.html#Navigating the Parse Tree (http://www.crummy.com/software/BeautifulSoup/bs3/documentation.html#Navigating the Parse Tree)
Title: Re: Internet Radio
Post by: nime5ter on July 16, 2013, 02:59:27 PM
Hmm. I will leave it to you full-on nerdz to figure that out. Back to work here.
Title: Re: Internet Radio
Post by: jitterjames on July 16, 2013, 04:09:25 PM
Since I am the "head nerd" around these parts, and because I can't resist playing the regex game, I've done the easiest thing based on the movie challenge.

This command will list the movies playing today for your location.  I've used my postal code for the imdb URL so for it to be of any use to you, you would need to modify the URL in the scrape action.

[26-MARCH-2015 -- While the concept is still valid, you will need to update the regular expression in the command below for this command to work because the IMDB website has changed since this was posted.]

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="176" name="local movies today" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape</cmdType>
    <cmdString>http://www.imdb.com/showtimes/location/CA/J0R1H0</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <cmdString>alt="(.*?)\bPoster"</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.MatchConcat</cmdType>
    <cmdString>{CR}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <cmdString>{LastResult}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>local movies today</phrase>
</command>
Title: Re: Internet Radio
Post by: Graves on August 14, 2013, 03:04:15 AM
Is there anyway to add 2 stations.  What i mean is say.  Computer play radio. Computer  response would be- which station would u prefer rock or metal.  Then i would say which one and it would play it.  And an option to change stations as well by saying change station.  Im still getting the hang of this.
Title: Re: Internet Radio
Post by: jitterjames on August 14, 2013, 08:50:06 AM
Typically, we would just create one command for each station.

Play me some rock radio

Play me some metal radio

There is no need for the other back and forth conversation with TTS really, but you can create the "fluff" if you want.  The concept of an actual menu of choices does not exist in VoxCommando yet.

What would the "change station" command actually do?  Play the "other" station?  Play one at random?
Title: Re: Internet Radio
Post by: Graves on August 14, 2013, 10:01:49 AM
The change station would be to go to the next one or possibly random.  I see what ur saying that making two commands Would be best.  I was trying to make a Jarvis lol.
Title: Re: Internet Radio
Post by: nime5ter on August 14, 2013, 11:23:57 AM
Typically, we would just create one command for each station.

Play me some rock radio

Play me some metal radio


Although this doesn't address the Jarvis issue or random station playing, the actual selection of rock station/metal station/talk radio station could be done in one command using a payload XML solution similar to what I did here: http://voxcommando.com/forum/index.php?topic=1119.0.

In that case, "rock" or "metal" would only play the one particular stream you've assigned to each genre though. To have VC randomly choose a stream from a library of streams in the 'rock' genre would require something more elaborate.
Title: Re: Internet Radio
Post by: jitterjames on August 21, 2013, 11:29:21 AM
Here is a quite a fancy set of commands for playing radio streams from "Shoutcast"

You request a genre of music, and then VC will go load a list of shoutcast stations for that genre, select one at random, and start playing it.

Streams can either be played directly from VC or they can be opened in another program like mediaMonkey, or iTunes

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<commandGroup open="True" name="shoutcast" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="184" name="playRadioMatch" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="Creates a playlist file using an URL stored as a match in the &quot;shoutcast genre&quot; command, and then opens it with the default program associated with .pls files.&#xD;&#xA;&#xD;&#xA;Alternatively the stream could be opened directly in VoxCommando.">
    <action>
      <cmdType>Scrape</cmdType>
      <cmdString>{Match.{1}}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>File.Write</cmdType>
      <cmdString>radio.pls&amp;&amp;{LastResult}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Launch.OpenFile</cmdType>
      <cmdString>radio.pls</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <cmdString>File.=(.*)</cmdString>
      <cmdRepeat>0</cmdRepeat>
    </action>
    <action>
      <cmdType>Sound.PlayStream</cmdType>
      <cmdString>{Match.1}</cmdString>
      <cmdRepeat>0</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <cmdString>Title.=\(.*?\)(.*)</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <cmdString>Now playing {Match.1}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <cmdString>Now playing {Match.1}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>playRadioMatch</event>
  </command>
  <command id="167" name="shoutcast genre" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="Given a genre as payload {1} this command will scan the various shoutcast radio stations available matching that genre.  These feeds are all stored as matches using RegEx.  It will thengenerate a random number (using Python) that is used to select a station.  An event &quot;playRadioMatch&quot; is then generated with the random number as the payload.  See the command &quot;playRadioMatch&quot; to see how the station is then played.">
    <action>
      <cmdType>VC.Off</cmdType>
      <cmdString />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Sound.StopStream</cmdType>
      <cmdString />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Stop</cmdType>
      <cmdString />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <cmdString>searching for {1} stations</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Scrape</cmdType>
      <cmdString>http://www.shoutcast.com/radio/{1}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <cmdString>href="(.*?)".*?class="playbutton</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>PY.ExecString</cmdType>
      <cmdString>import random</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>PY.ExecString</cmdType>
      <cmdString>result = random.randint(1,{#M})</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <cmdString>Found {#M} stations, playing number {LastResult}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.TriggerEvent</cmdType>
      <cmdString>playRadioMatch&amp;&amp;{LastResult}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>shoutcast, radio</phrase>
    <phrase>genre, station</phrase>
    <payloadList>Alternative,Blues,Classical,Country,Decades,Easy Listening,Electronic,Folk,Inspirational,International,Jazz,Latin,Metal,Misc,New Age,Pop,Public Radio,Rap,Reggae,Rock,Baroque,Soundtracks,Talk,Themes</payloadList>
  </command>
  <command id="185" name="stop stream" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Sound.StopStream</cmdType>
      <cmdString />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>stop stream</phrase>
  </command>
</commandGroup>
Title: Re: Internet Radio
Post by: StrikemanXL on August 22, 2013, 04:08:49 PM
I get this error when I run your above code
22/08/2013 19:50:54   914   received udp command:vc.tellvox&&radio genre Baroque
22/08/2013 19:50:54   914   action repeat set to: 1
22/08/2013 19:50:54   914   Action:  vc.tellvox - radio genre Baroque
22/08/2013 19:50:54   920   emulating recognition on string:radio genre Baroque
22/08/2013 19:50:54   966   semanticID: 172
22/08/2013 19:50:54   967   kvp: command | 172
22/08/2013 19:50:54   967   kvp: p172d1 | Baroque
22/08/2013 19:50:54   968   semanticID: 172
22/08/2013 19:50:54   969   kvp: command | 172
22/08/2013 19:50:54   969   kvp: p172d1 | Baroque
22/08/2013 19:50:54   969   alternate:radio genre Baroque
22/08/2013 19:50:54   991   doCommand:shoutcast genre
22/08/2013 19:50:54   992   action repeat set to: 1
22/08/2013 19:50:54   992   Action:  VC.Off -
22/08/2013 19:50:55   5   action repeat set to: 1
22/08/2013 19:50:55   5   Action:  Sound.StopStream -
22/08/2013 19:50:55   8   System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
   at System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
   at System.Windows.Forms.Control.Invoke(Delegate method)
   at r.a(bv A_0, List`1 A_1)
   at r.b(ba A_0)
   at r.a(ba A_0)
   at r.a(Object A_0, SpeechRecognizedEventArgs A_1)

btw im using VC version 1.1.0.0  because when i click on the dropbox link you posted for VC 1.132  it says its empty.....
Title: Re: Internet Radio
Post by: jitterjames on August 22, 2013, 05:55:40 PM
Sorry.  You can get the latest version here: http://voxcommando.com/forum/index.php?topic=1164.0

You will need to enable the python plugin (py) in VC options and you need something installed that can play .pls (playlist files)

Or if you want to play the stream directly in VC you can edit the command "playRadioMatch".

-Disable the actions (File.Write and Launch.OpenFile) by changing the 1s to 0s (or delete the actions)
-Enable the next two actions that are currently being skipped by changing the 0s to 1s
Title: Re: Internet Radio
Post by: StrikemanXL on August 23, 2013, 04:59:29 AM
Thanks JJ that worked a treat and the new VC version works great :) thank you.
I found this to open .pls files in WMP http://openplsinwmp.codeplex.com/
Title: Re: Internet Radio
Post by: jitterjames on August 23, 2013, 09:21:14 AM
Thanks.  I believe both MediaMonkey and iTunes can open them without modification.
Title: Re: Internet Radio
Post by: nime5ter on August 23, 2013, 11:48:50 AM
FWIW, on my Windows 8 machine I had no difficulty getting the code to work, streaming using MediaMonkey, but when I tried to add a Stop Stream command (MM.Stop or MM.Pause etc.) I got an error and could not get the stream to stop.

I was able to fix the problem by setting both Media Monkey and VC to "run as administrator". If you're having similar difficulties, give this a whirl.

I am using VC 1.1.4.0, but had the same issue when I tried using an earlier 1.1x version (I forget which).
Title: Re: Internet Radio
Post by: jitterjames on August 23, 2013, 06:00:32 PM
I believe this is an issue with the MediaMonkey com library that VC uses to communicate with MediaMonkey.  It seems to behave differently on different systems, but the problem actually has nothing to do with streaming audio in particular.  If you try any command from VC to control MediaMonkey you will have this issue.

On my various windows systems (including a win8.1 preview) I have not had this problem even with UAC turned on.  I only needed to run MM once as administrator and from then on no problems, and I never have to run VC as admin.  I don't know why your system is different but seeing is believing!
Title: Re: Internet Radio
Post by: Tecni on October 09, 2013, 04:06:41 AM
 Hi,I try modify the script for radio.de but dosnt work. Need a little bit help ^^ with Results.RegEx action. Ty

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="333" name="radioscrape" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape</cmdType>
    <cmdString>http://www.radio.de/#%2Fsendersuche.jsf%3Fq%3D{1}%26u%3Dall</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>

 
Title: Re: Internet Radio
Post by: Kalle on October 09, 2013, 04:50:27 AM
Hi Tecni and welcome to VC forum.
I'm not sure which script you mean (there are more then one script in this topic)  ;)
You can post a VC command group by using the square icon above (#), so we can take a look on it.
Title: Re: Internet Radio
Post by: Tecni on October 09, 2013, 07:24:02 AM
I want use this script for radio.de

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="798" name="shoutcast genre" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>VC.Standby</cmdType>
    <cmdString />
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTS.Stop</cmdType>
    <cmdString />
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Scrape</cmdType>
    <cmdString>http://www.shoutcast.com/radio/{1}</cmdString>      (for radio.de <cmdString>http://www.radio.de/#%2Fsendersuche.jsf%3Fq%3D{1}%26u%3Dall</cmdString> )
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <cmdString>href="(.*?)".*?class="playbutton</cmdString>             (dont know... tried  id )
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>PY.ExecString</cmdType>
    <cmdString>import random</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>PY.ExecString</cmdType>
    <cmdString>result = random.randint(1,{#M})</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTS.Speak</cmdType>
    <cmdString> {#M} Radiosender gefunden, spiele nummer {LastResult}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.TriggerEvent</cmdType>
    <cmdString>playRadioMatch&amp;amp;&amp;amp;{LastResult}</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.Standby</cmdType>
    <cmdString />
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>shoutcast, inizialisiere radio</phrase>
  <phrase>genre, station</phrase>
  <payloadList>Alternative,Blues,Classical,Country,Decades,Easy Listening,Electronic,Metal,Oldies,New Age,Pop,Public Radio,Rap,Reggae,Rock,</payloadList>
</command>
Title: Re: Internet Radio
Post by: nime5ter on October 09, 2013, 01:33:32 PM
I'm happy to help you with the regex, but since the site you are using works differently from shoutcast, you'll have to do more than get the regex right for this command to work properly.

To return a list of URL matches for the genre of radio stations you've asked for, you can use the regex:
Code: [Select]
cmdType>Results.RegEx</cmdType>
    <cmdString>linkobject=.*url\'\:\'(.*?)\'.*?bcastid=</cmdString>
    <cmdRepeat>1</cmdRepeat>

(This is when scraping the URL that you provided for us: http://www.radio.de/#%2Fsendersuche.jsf%3Fq%3D{1}%26u%3Dal )

However, the rest of James's original command group is designed to work with .pls multimedia playlists, whereas your site uses a built-in Flash player for each radio station.

You can still use the above regex to get the station URLs, but I imagine you'll want to use the Launch.URL action or something like that to open one of those matches in your browser. The challenge will be in finding a way to return a random match from the list of URLs.

Let us know if you'd like more help with that. It might be fun to try on your own first, so I am just answering the question that you initially posed. :)
Title: Re: Internet Radio
Post by: nime5ter on October 10, 2013, 04:26:27 PM
If you use XBMC, see also: http://voxcommando.com/forum/index.php?topic=1216.0
Title: Re: Internet Radio
Post by: jitterjames on October 14, 2013, 10:37:44 PM
Here is a group of commands that work with rad.io (and radio.de with minor adjustment) but you will need VC version 1.163 for it to work.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<commandGroup open="True" name="scrape rad io" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="1120" name="radio play genre {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Scrape.UserAgent</cmdType>
      <cmdString>http://www.rad.io/info/menu/broadcastsofcategory?category=_genre&amp;value={1}&amp;&amp;VoxCommando</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <cmdString>"id":(.*?),</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="True">
      <ifType>LastActionSuccess</ifType>
      <ifParams>&amp;&amp;</ifParams>
      <then>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <cmdString>Error.</cmdString>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>VC.StopMacro</cmdType>
          <cmdString />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else />
    </if>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <cmdString>radioID&amp;&amp;{Match.Rnd}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Scrape.UserAgent</cmdType>
      <cmdString>http://www.rad.io/info/broadcast/getbroadcastembedded?broadcast={Var.radioID}&amp;&amp;VoxCommando</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <cmdString>"(?:streamUrl|name|description)":"(.*?)"</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <cmdString>Now Playing {Match.3}, {Match.2}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Sound.PlayStream</cmdType>
      <cmdString>{Match.1}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Sound.SetStreamVol</cmdType>
      <cmdString>50</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <cmdString>Now Playing {Match.3}, {Match.2}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>radio play genre</phrase>
    <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\RadioGenres.xml</payloadFromXML>
  </command>
  <command id="1101" name="set stream volume" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Sound.SetStreamVol</cmdType>
      <cmdString>{1}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>set stream volume</phrase>
    <payloadList>10,20,30,40,50,60,70,80,90,100</payloadList>
  </command>
  <command id="1116" name="what radio station is this" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Sound.GetStreamInfo</cmdType>
      <cmdString />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <cmdString>name:(.*)</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <cmdString>{Match.1}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <cmdString>You are listening to: {Match.1}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>what radio station is this</phrase>
  </command>
  <command id="1134" name="sound.getstreaminfo" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>OSD.SetFontSize</cmdType>
      <cmdString>14</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Sound.GetStreamInfo</cmdType>
      <cmdString />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <cmdString>{LastResult}&amp;&amp;6000&amp;&amp;-100</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>System.SetClipboardText</cmdType>
      <cmdString>{LastResult}</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
  </command>
  <command id="188" name="radio stop" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Sound.StopStream</cmdType>
      <cmdString />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>radio stop</phrase>
  </command>
</commandGroup>
Title: Re: Internet Radio
Post by: Tecni on October 16, 2013, 01:25:20 PM
Thanks  :) :) i test it later.
Title: Re: Internet Radio
Post by: jitterjames on October 22, 2013, 08:42:36 AM
Yes.  You should.
Title: Re: Internet Radio
Post by: Tecni on October 25, 2013, 08:26:49 AM
Works well.Thanks

Is it possible to write the url in a pls data? ::)
Title: Re: Internet Radio
Post by: Kalle on October 30, 2013, 08:17:02 AM
create as new from the post above

Is it possible to write the url in a pls data? Roll Eyes
Title: Re: Internet Radio
Post by: jitterjames on October 30, 2013, 08:48:00 AM
Was that supposed to be a bump?

The answer is yes.

A more detailed question will result in a more detailed answer.  >:D
Title: Re: Internet Radio
Post by: nime5ter on October 30, 2013, 02:03:23 PM
create as new from the post above

Is it possible to write the url in a pls data?  ::)

The problem with this question is that we don't have any idea what the user actually wants, or what his or her set-up is at home.

There are various "correct" ways to respond, and the correct answer for Tecni's needs will depend on *why* Tecni thinks he (or she) needs to write a URL to a pls.

It is better to explain what you want to do with the pls, rather than asking a general question that requires us to imagine what you are actually trying to do.

When we don't know how someone is using VoxCommando and we try to guess, we end up wasting a lot of our time providing a million different solutions, none of which seems to be what the user wants.

Here is one example of a very specific, detailed question that we can answer:

Quote
I am using VC version 1.166.

I would like to play the radio audio stream using XBMC Frodo's native "My Audio" player rather than using VoxCommando like James is doing in his command above. This is because I want to play the stream on a different computer on my network -- not the computer that is running VoxCommando.

To do this, I want to create a pls file based on the streamURL returned in James's command and pass that information to XBMC running on a different computer.

How can I do that? And does this sound like the best solution?

Title: Re: Internet Radio
Post by: Kalle on October 30, 2013, 04:08:36 PM
Hi Naomi, you're talking out of my soul and I think we need some forum rules (or did we have some?). Your post is a really good start. Maybe it makes sense if we can deactivate the PM function  ::hmm
I know that would be nice to have a private support, but James and some other helpers are not micosoft which have his own support section with hunderts of employee. If everyone post in the forum, there are more opportunities to help by other users.  :bignod
Title: Re: Internet Radio
Post by: jitterjames on October 30, 2013, 04:27:10 PM
I agree Kalle.

However, I do not wish to disable the PM function because it is still a valid tool for users when used properly, and not everyone wants to make their email address public so PM is the only option for private communication.

I do think that we need some forum rules and guidelines, but creating the rules is just one more job for me that I have not found the time to take care of.  There is also the feeling that even if I create them, many users will simply disregard them.  My currently signature does not seem to be having much effect.

If users don't follow the rules (within reason) then I guess we will need to start banning people that do not respond to warnings.  :(

I think we can pretty much copy and paste the forum rules from XBMC without too many modifications.

http://wiki.xbmc.org/index.php?title=Forum_rules#ADVICE:_How_do_I_ask_a_question_in_a_smart_way.3F

This issue happened to come up in the Internet Radio thread, but it is a common problem.  It is not intended as an attack on any individual user, but in this thread we see an example of a user who would benefit from reading and understanding these concepts.  I am always happy to provide support to any user when I can.  But I prefer to help people who can ask meaningful questions without wasting my time.  Also, bothering forum members by asking for help through the private message system is simply not acceptable.
Title: Re: Internet Radio
Post by: FallenOne on November 15, 2013, 01:44:40 PM
soo.. digging out the old thread.

first of all, thanks for introducing me to radio paradise ;) love it.
second of all, in your command you use "Sound.SetVol" to adjust the streams volume.

well.. sort of... while Sound.SetVol controls the system volume, i can't really hear the tts when it is turned down ;)

so i looked into some commands and found "Sound.SetStreamVol" . what i encountered was that basically it adjusts the volume independent from the system volume slider, but it also affects the tts voice :C
now the question is: is there a way to regulate the stream volume, while keeping the tts voice at the same volume?
Title: Re: Internet Radio
Post by: jitterjames on November 15, 2013, 01:51:53 PM
I don't think so.  This seems to be a peculiarity of windows and/or .Net

I was surprised to discover this myself.

If this is a big enough problem for you then I recommend that you instead play the stream using a separate program like MediaMonkey, iTunes, Windows media player etc.
Title: Re: Internet Radio
Post by: FallenOne on November 15, 2013, 01:53:30 PM
but....but... this is so all-in-one-convinient ;)

well... time to get media monkey i guess ;) thanks for the fast answer!

Title: Re: Internet Radio
Post by: MrWolf on December 01, 2013, 11:52:27 AM
James, stumbling across your code for getting local cinema information was a very happy accident.

I have a couple issues if you can help...

How do I get the display to stay on the screen for a longer period/on until I tell it to go away?

When I use the command there are too many movies to fit in the black window, any way to shrink to fit?

-P
Title: Re: Internet Radio
Post by: jitterjames on December 01, 2013, 12:00:10 PM
If you look at the parameters avaialable for Osd.ShowText you will see that there is one for duration.  Just indicate in milliseconds how long you want it to stay on screen.
http://voxcommando.com/mediawiki/index.php?title=Actions#ShowText

There is no way to tell it when to hide the osd.

You can set the font size as well using Osd.SetFontSize
http://voxcommando.com/mediawiki/index.php?title=Actions#SetFontSize

Title: Re: Internet Radio
Post by: jitterjames on December 01, 2013, 12:05:07 PM
Actually, you could show osd with a really long duration (say 90000 for 90 seconds) and then hide it using osd.showtext with a very short duration like 5 milliseconds.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<commandGroup open="True" name="osd test" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="206" name="show long osd" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <cmdString>this is a test&amp;&amp;90000</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>show long osd</phrase>
  </command>
  <command id="219" name="hide osd" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <cmdString>hiding...&amp;&amp;50</cmdString>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>hide osd</phrase>
  </command>
</commandGroup>
Title: Re: Internet Radio
Post by: MrWolf on December 01, 2013, 03:09:34 PM
I wonder how many beers I'm gonna owe you before today is through ;)

I shall try this stuff out (and all the other helps you've given me) as soon as Neesha is at work or studying.

I'll let you know how I get on.

xxx
Title: Re: Internet Radio
Post by: lja on June 08, 2014, 06:59:14 PM
I have been trying to set up  internet radio using xml from here. I have been able to get the station to play but am having difficulty in coding for the info. Please help with how do I find the URL to scrape from the website. The site is www.smoothjazzflorida.com. While this is specific, I would like to understand the process. Thanks.
Title: Re: Internet Radio
Post by: nime5ter on June 08, 2014, 09:04:35 PM
There are several different xml posts in this thread. Which xml you are using, exactly?
Title: Re: Internet Radio
Post by: jitterjames on June 08, 2014, 09:11:06 PM
Just to clarify:

You are able to play the stream, but you want to know how you can ask about what current song is playing, and what artist and album it is.  Is that correct?
Title: Re: Internet Radio
Post by: lja on June 08, 2014, 11:36:15 PM
Just to clarify:

You are able to play the stream, but you want to know how you can ask about what current song is playing, and what artist and album it is.  Is that correct?

Yes. That is correct.
Title: Re: Internet Radio
Post by: lja on June 09, 2014, 02:36:41 AM
There are several different xml posts in this thread. Which xml you are using, exactly?

Radio Paradise by jitterjames. While I was able to get the stream working,  it would also be good to understand how to locate the info for the stream.
Title: Re: Internet Radio
Post by: jitterjames on June 09, 2014, 08:19:13 AM
Radio paradise is a class 1 radio station.  They provide an XML now playing feed which is easy to read.  Trying to do this with a generic shoutcast radio station is a completely different story.  Finding a page with now playing information on it is not so easy.  It actually seems like shoutcast has tried to make it difficult for us. Nime5ter is working on a solution using robobrowser, but it may not work for all shoutcast stations.  You will need to manually inspect the pls file for a given station to find the IP address of the stream.
Title: Re: Internet Radio
Post by: lja on June 09, 2014, 09:12:53 AM
Radio paradise is a class 1 radio station.  They provide an XML now playing feed which is easy to read.  Trying to do this with a generic shoutcast radio station is a completely different story.  Finding a page with now playing information on it is not so easy.  It actually seems like shoutcast has tried to make it difficult for us. Nime5ter is working on a solution using robobrowser, but it may not work for all shoutcast stations.  You will need to manually inspect the pls file for a given station to find the IP address of the stream.

Thanks. Will await possible solution while I read some more.
Title: Re: Internet Radio
Post by: nime5ter on June 09, 2014, 09:38:11 AM
Actually, we don't need to use the RoboBrowser plugin after all, though it's one option.

It seems that Shoutcast feeds require a get request that specifies a "user agent". We have a specific scrape action for such sites in VC: http://voxcommando.com/mediawiki/index.php?title=Actions#Scrape

There is no universal, easy answer for how to find the information we need, unfortunately. If looking at a site's page source directly doesn't give the answer, then we have to dig a little, do some web searches, etc.

In the case of your particular jazz feed, I was able to look at the pls file (I used Notepad++) to find the URL for that stream. When I went to that page, I saw it had what looked like scrape-able song information on it. When I tried to use a regular scrape, I got an error. I was able to use RoboBrowser instead, but this is much less efficient. Looking up that error and how Shoutcast works, we figured out that they require user agent info in the header, so I used that action instead, and was able to scrape the page that contains now playing data.

Basically, if you have the time/interest in investigating and finding a solution, there usually is one, but there are no hard and fast rules. Different sites work differently.

The folllowing command gets the current song data for the Florida jazz stream:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.5.5-->
<command id="279" name="get Florida Jazz song info" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape.UserAgent</cmdType>
    <params>
      <param>http://38.96.175.21:8802</param>
      <param>Mozilla</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>System.SetClipboardText</cmdType>
    <params>
      <param>{LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>Current.Song:.*?&lt;b&gt;(.*?).-.(.*?)&lt;/b&gt;</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>Artist: {Match.1.1}{cr}Song: {Match.1.2}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTS.Speak</cmdType>
    <params>
      <param>This is the song {Match.1.2}, by the artist {Match.1.1}.</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>get song info</phrase>
</command>

(Note that my regular expression won't work if you're using version 1 of VC, but the regular expression can be re-written if needed. It's just that VC2 offers much more efficient syntax for such things.)
Title: Re: Internet Radio
Post by: lja on June 09, 2014, 12:33:22 PM
Actually, we don't need to use the RoboBrowser plugin after all, though it's one option.

It seems that Shoutcast feeds require a get request that specifies a "user agent". We have a specific scrape action for such sites in VC: http://voxcommando.com/mediawiki/index.php?title=Actions#Scrape

There is no universal, easy answer for how to find the information we need, unfortunately. If looking at a site's page source directly doesn't give the answer, then we have to dig a little, do some web searches, etc.

In the case of your particular jazz feed, I was able to look at the pls file (I used Notepad++) to find the URL for that stream. When I went to that page, I saw it had what looked like scrape-able song information on it. When I tried to use a regular scrape, I got an error. I was able to use RoboBrowser instead, but this is much less efficient. Looking up that error and how Shoutcast works, we figured out that they require user agent info in the header, so I used that action instead, and was able to scrape the page that contains now playing data.

Basically, if you have the time/interest in investigating and finding a solution, there usually is one, but there are no hard and fast rules. Different sites work differently.



Thanks. Got it working. With the info provided I will play with it further to see if I have any additional questions. There is one thing I have noticed. The voice providing the info is very low. Can the volume level of the stream be reduced ?
Title: Re: Internet Radio
Post by: jitterjames on June 09, 2014, 01:22:11 PM
We appreciate it if you to try to look a bit before you ask.  This information should be easy to find in the wiki if you look.

http://voxcommando.com/mediawiki/index.php?title=Actions#SetStreamVol

http://voxcommando.com/forum/index.php?topic=1140.msg10852#msg10852
Title: Re: Internet Radio
Post by: lja on June 09, 2014, 01:54:22 PM
We appreciate it if you to try to look a bit before you ask.  This information should be easy to find in the wiki if you look.

http://voxcommando.com/mediawiki/index.php?title=Actions#SetStreamVol

http://voxcommando.com/forum/index.php?topic=1140.msg10852#msg10852

Thanks. Sorry about that.
Title: Re: Internet Radio
Post by: lja on June 12, 2014, 12:23:56 AM
@nime5ter
Since your kind assistance, I have been searching the web for help to learn more on how to get song info from internet radio websites. I am using this site as my test:

http://www.internet-radio.com/station/allirishradio/.

I have got it setup to stream and the info I now need for this site is the scrape url similar to the undernoted. I am not asking you to do the work but wonder if you can provide any additional guidance to that previously included in your post above. I have tried a number of suggestions I found on the net but none of them helped.

<param>http://38.96.175.21:8802</param>

Thanks.
Title: Re: Internet Radio
Post by: nime5ter on June 12, 2014, 09:22:09 AM
Hi lja,

I'm sorry, I'm not sure what you are looking for at this point.

Your internet-radio.com webpage is showing a stream for Irish KISS FM. If that's the stream you're interested in, you have at least 2 options.

1. Follow the link that they provide to the radio station's website. There you can see a link to their "last 10 played" page. The top song is the currently playing song, so you could scrape that page if you like.

Or:

2. Do the same thing that I did with the jazz station example. Download the Ireland's KISS FM playlist file (m3u or pls or whatever) that is available at the link you posted above. You mention that you're able to set up the stream, so it sounds as though you've found that.

That file contains the URL (sometimes more than one, but in this case, just one) that you want to scrape. You can enter that URL directly in your web browser. It is exactly like the Smooth Jazz example.

If you compare the information contained on that page to the "Last 10 Played on KISS FM Ireland" page, you'll see that they both show the currently playing song, along with some other, different data.

I apologize if I'm misunderstanding what you're asking, but hopefully that helps.
Title: Re: Internet Radio
Post by: nime5ter on June 12, 2014, 09:33:33 AM
And of course, you can always try playing the radio streams in your favourite media player -- XBMC, MM or whatnot, and get the "now playing" information through the relevant VC commands.

There are Shoutcast and Icecast addons for XBMC, among other Internet radio options.
Title: Re: Internet Radio
Post by: lja on June 12, 2014, 03:48:11 PM
Hi lja,

I'm sorry, I'm not sure what you are looking for at this point.

Your internet-radio.com webpage is showing a stream for Irish KISS FM. If that's the stream you're interested in, you have at least 2 options.

1. Follow the link that they provide to the radio station's website. There you can see a link to their "last 10 played" page. The top song is the currently playing song, so you could scrape that page if you like.

Or:

2. Do the same thing that I did with the jazz station example. Download the Ireland's KISS FM playlist file (m3u or pls or whatever) that is available at the link you posted above. You mention that you're able to set up the stream, so it sounds as though you've found that.

That file contains the URL (sometimes more than one, but in this case, just one) that you want to scrape. You can enter that URL directly in your web browser. It is exactly like the Smooth Jazz example.

If you compare the information contained on that page to the "Last 10 Played on KISS FM Ireland" page, you'll see that they both show the currently playing song, along with some other, different data.

I apologize if I'm misunderstanding what you're asking, but hopefully that helps.

Thanks. No apology necessary as you did understand what I was asking. I will check this out.
Title: Re: Internet Radio
Post by: lja on June 12, 2014, 03:50:15 PM
And of course, you can always try playing the radio streams in your favourite media player -- XBMC, MM or whatnot, and get the "now playing" information through the relevant VC commands.

There are Shoutcast and Icecast addons for XBMC, among other Internet radio options.

Thanks. I will also check this. I will do some searching re the commands.
Title: Re: Internet Radio
Post by: lja on June 16, 2014, 11:25:00 AM
@nime5ter

Thanks very much for all your help. I have finally been able to locate the urls and tested on a few stations.
Title: Re: Internet Radio
Post by: jesusq on June 23, 2014, 02:40:45 PM
Awesome
Title: Re: Internet Radio
Post by: Hiryu on August 16, 2014, 11:52:56 AM
Newbie here -- tried to copy and paste the initial post code.  When I say the command "start the stream" the history log returns "can't find command: The given key was not present in the dictionary."

First time encountering this so was wondering what that means?  I tried restarting VC, rebuilding grammars.  I'm on VC 2.0.0.0 SP. 

Appreciate the help.
Title: Re: Internet Radio
Post by: nime5ter on August 16, 2014, 01:43:03 PM
Hm. If you mean jitterjames's xml here: http://voxcommando.com/forum/index.php?topic=1140.msg9570#msg9570 -- I am not running into any problems in either SP or the standard versions. I am using a later version than 2.0, but I don't think it matters.

Have you tried purging your cache yet?
Title: Re: Internet Radio
Post by: jitterjames on August 16, 2014, 02:17:02 PM
There is nothing wrong with the xml.  I also recommend purging your cache.

- File >> Purge Cache
- File >> Full Restart

You should also check that you don't have duplicate group names for some reason.

If none of that helps you should post a full log.
Title: Re: Internet Radio
Post by: Hiryu on August 16, 2014, 03:24:59 PM
It's the weirdest thing -- I had tried all that, purging the cache, full restart, closing down the application and then restarting.  Going through all of that again.  For some reason, it just kept giving me the same log message.  Waited a while, came back to it, restarted VC and then it started working!

Seems ok for now -- thanks!

Sorry -- didn't mean to imply that the XML wasn't working, I knew it had to be some user error or something going on with the PC on my end.
Title: Re: Internet Radio
Post by: jitterjames on August 16, 2014, 04:07:53 PM
Sorry -- didn't mean to imply that the XML wasn't working, I knew it had to be some user error or something going on with the PC on my end.
I didn't think you were implying anything, but sometimes older XML is no longer valid so I thought I should point out that it was still working for us.
Title: Re: Internet Radio
Post by: lja on October 02, 2014, 12:50:46 PM
Re: Reply #12 on: August 21, 2013, 10:29:21 am

I have been playing with this but so far, have been unable to get it to work. Before I continue, is the code still valid?  
Title: Re: Internet Radio
Post by: nime5ter on October 02, 2014, 01:12:02 PM
No, looks like the Shoutcast site has changed its stripes, so the XML posted here at http://voxcommando.com/forum/index.php?topic=1140.msg9864#msg9864 is no longer valid.

The history panel gives a pretty good indication of this if you try the commands. When it scrapes the Shoutcast site and tries to find matches for the regular expression, no matches are found.
Title: Re: Internet Radio
Post by: lja on October 02, 2014, 01:21:47 PM
No, looks like the Shoutcast site has changed its stripes, so the XML posted here at http://voxcommando.com/forum/index.php?topic=1140.msg9864#msg9864 is no longer valid.

The history panel gives a pretty good indication of this if you try the commands. When it scrapes the Shoutcast site and tries to find matches for the regular expression, no matches are found.

Thanks.
Title: Re: Internet Radio
Post by: lja on October 03, 2014, 05:17:29 PM
I have setup folder called "Net Radios" and in this folder are a number of internet stations, each with a specific payload.
To date using a variation of phrases for each station e.g. What station is this, Name this station etc., have had success.
Would like to ask: "What station is this" for each station, while the station is streaming using the same phrase.
If this is possible, would like some help please. Thanks.
Title: Re: Internet Radio
Post by: nime5ter on October 03, 2014, 05:32:11 PM
I have setup folder called "Net Radios" and in this folder are a number of internet stations, each with a specific payload.

By "setup folder" do you mean "command group"? http://voxcommando.com/mediawiki/index.php?title=Groups

If so, could you please post your Net Radios command group xml?  http://voxcommando.com/mediawiki/index.php?title=XML_on_the_forum#Posting_Your_Code_to_the_Forum

It will be easier for us to understand what you've accomplished so far and what you're still trying to do.
Title: Re: Internet Radio
Post by: lja on October 03, 2014, 05:59:10 PM
By "setup folder" do you mean "command group"? http://voxcommando.com/mediawiki/index.php?title=Groups

If so, could you please post your Net Radios command group xml?  http://voxcommando.com/mediawiki/index.php?title=XML_on_the_forum#Posting_Your_Code_to_the_Forum

It will be easier for us to understand what you've accomplished so far and what you're still trying to do.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.0.3-->
<commandGroup open="False" name="Net Radios Test" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="387" name="Listen to Net Radios" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>Which radio station would like to to listen to?|What station did you have in mind?|Sure, I can turn on the radio. What station should I tune to?</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Listen to net radios</phrase>
  </command>
  <command id="361" name="What are my options?" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="This is the easiest method but not the most sophisticated. There are almost always different ways to skin a cat in VC.">
    <action>
      <cmdType>PayloadXML.GetRandomP</cmdType>
      <params>
        <param>payloads\internet radios.xml</param>
        <param>100</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.MatchConcat</cmdType>
      <params>
        <param>{CR}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>What are my options?</phrase>
  </command>
  <command id="211" name="Smooth Jazz Florida" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Sound.PlayStream</cmdType>
      <params>
        <param>http://198.58.106.133:11094/</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Now playing Smooth Jazz Florida</param>
        <param>30000</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>play smooth jazz florida, stream florida jazz </phrase>
    <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">net radios payloads\smooth jazz florida.xml</payloadFromXML>
  </command>
  <command id="255" name="stop the stream" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Sound.StopStream</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>stop the stream, stop playing</phrase>
  </command>
  <command id="440" name="get Florida Jazz song info" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Scrape.UserAgent</cmdType>
      <params>
        <param>http://38.96.175.21:8802</param>
        <param>Mozilla</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>System.SetClipboardText</cmdType>
      <params>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>Current.Song:.*?&lt;b&gt;(.*?).-.(.*?)&lt;/b&gt;</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Artist: {Match.1.1}{cr}Song: {Match.1.2}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>This is the song {Match.1.2}, by the artist {Match.1.1}.</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>smooth jazz florida song info</phrase>
  </command>
  <command id="234" name="What station is this" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>PayloadXML.GetRandomP</cmdType>
      <params>
        <param>net radios payloads\smooth jazz florida</param>
        <param>100</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.MatchConcat</cmdType>
      <params>
        <param>{CR}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>What station is this</phrase>
  </command>
  <command id="240" name="The Source KJAC" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Sound.PlayStream</cmdType>
      <params>
        <param>http://149.255.33.76:8110/</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Play the source</phrase>
  </command>
  <command id="239" name="get The Source song info" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Scrape.UserAgent</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>System.SetClipboardText</cmdType>
      <params>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>Current.Song:.*?&lt;b&gt;(.*?).-.(.*?)&lt;/b&gt;</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Artist: {Match.1.1}{cr}Song: {Match.1.2}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>This is the song {Match.1.2}, by the artist {Match.1.1}.</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>the source song info</phrase>
  </command>
  <command id="231" name="What station is this" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>PayloadXML.GetRandomP</cmdType>
      <params>
        <param>net radios payloads\the source</param>
        <param>100</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.MatchConcat</cmdType>
      <params>
        <param>{CR}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{Match.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>What station is this, Name this station</phrase>
  </command>
</commandGroup>


https://dl.dropboxusercontent.com/u/19298307/net%20radios%20payloads/smooth%20jazz%20florida.xml

https://dl.dropboxusercontent.com/u/19298307/net%20radios%20payloads/the%20source.xml
Title: Re: Internet Radio
Post by: nime5ter on October 03, 2014, 10:31:11 PM
Thanks for posting your xml. I wouldn't have understood what was happening without being able to see your commands.

I've made some revisions to your command group. Within each command, I've added a description to try to explain what is happening.

If you copy the command group into your tree, you can open up each command to read the explanation.

I recommend that you delete your current command group before trying to use this new version, because otherwise you'll have two groups in your tree that use the same command phrases and VC will get confused. If you want to revert back to your original commands, you can simply grab them again from this thread.

You'll also need to download the attached payload xml file and place it in your "net radio payloads" folder.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.0.3-->
<commandGroup open="True" name="New Net Radios" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="393" name="Listen to Net Radios" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>Which radio station would like to to listen to?|What station did you have in mind?|Sure, I can turn on the radio. What station should I tune to?</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>Listen to net radios</phrase>
  </command>
  <command id="367" name="What are my options?" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="This reads (scrapes) your payload xml file with all the radio station names. It finds the first phrase for each station name (because the file includes different ways to say the same station name -- e.g. &quot;Smooth Jazz Florida&quot; or just &quot;Smooth Jazz&quot;). It then creates a list of all the stations by concatenating (joining together) all of the stations it has matched. {CR} is a carriage return. It makes sure that each match found  is listed on its own line.&#xD;&#xA;&#xD;&#xA;This is more complicated than you need for your simple list of 2 stations. But if you eventually want to add different ways to say the same station name then this solution should be more robust.">
    <action>
      <cmdType>File.Read</cmdType>
      <params>
        <param>net radio payloads\internet radio stations.xml</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>&lt;phrase&gt;(.*?)[,|&lt;]</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.MatchConcat</cmdType>
      <params>
        <param>{CR}</param>
        <param>20</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>What are my options?</phrase>
  </command>
  <command id="217" name="Play shoutcast radio station" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="Since both of your radio stations (Smooth Jazz &amp; The Source) are Shoutcast stations, you don't need to have so many separate commands. Payloads allow you to re-use command structures when they follow all the same rules.&#xD;&#xA;&#xD;&#xA;For these Shoutcast stations, you need just one single payload xml file. Each radio station has a phrase -&gt; value pair of &quot;radio station name&quot; -&gt; &quot;URL&quot;. When you ask VC to play a radio station, it looks for the station name and finds the associated URL in the payload XML file. The syntax {1} refers to the payload value. In this command, when you ask for a specific station, it will consult the payload XML station, find the associated URL, and then use that URL in all 3 actions that you can see above.&#xD;&#xA;&#xD;&#xA;Previously, you had 2 payload XML files, but you weren't actually passing the payload values to the command. Instead, you had hard-coded the URL in each command. VC was looking in those files for the radio station name, but it did nothing at all with the URL (payload value).">
    <action>
      <cmdType>Sound.PlayStream</cmdType>
      <params>
        <param>{1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>nowplaying</param>
        <param>{1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>PayloadXML.GetPhrase</cmdType>
      <params>
        <param>net radio payloads\internet radio stations.xml</param>
        <param>{1}</param>
        <param>Random</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>Now playing {LastResult}</param>
        <param>30000</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>Now playing {LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>play </phrase>
    <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">net radio payloads\internet radio stations.xml</payloadFromXML>
  </command>
  <command id="268" name="stop the stream" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Sound.StopStream</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>nowplaying</param>
        <param>no radio</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>stop the stream, stop playing</phrase>
  </command>
  <command id="453" name="get song info" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="In your &quot;play [radio station x]&quot; command, I added an action that stores the radio station URL as a variable called &quot;nowplaying&quot;. This allows VC to &quot;know&quot; what station is currently playing. Then we can use that variable in other commands. Here we are using it to tell VC which radio station URL to scrape to find out what song is playing.&#xD;&#xA;&#xD;&#xA;If you stop the internet radio stream, the &quot;nowplaying&quot; variable is set to &quot;no radio&quot;. (See the &quot;stop the stream&quot; command.) Here in this command, I tell VC that if the &quot;nowplaying&quot; variable contains the words &quot;no radio&quot; it should do nothing at all (exit this macro). Otherwise, it should look up the currently playing song info at the URL provided.">
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)Contains(B)</ifType>
      <ifParams>{var.nowplaying}&amp;&amp;no radio</ifParams>
      <then>
        <action>
          <cmdType>VC.StopMacro</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>Scrape.UserAgent</cmdType>
          <params>
            <param>{var.nowplaying}</param>
            <param>Mozilla</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>System.SetClipboardText</cmdType>
          <params>
            <param>{LastResult}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>Results.RegEx</cmdType>
          <params>
            <param>Current.Song:.*?&lt;b&gt;(.*?).-.(.*?)&lt;/b&gt;</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>OSD.ShowText</cmdType>
          <params>
            <param>Artist: {Match.1.1}{cr}Song: {Match.1.2}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>This is the song {Match.1.2}, by the artist {Match.1.1}.</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <phrase>song info, what song is this, what's playing right now</phrase>
  </command>
  <command id="247" name="What station is this" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="In your &quot;play [radio station x]&quot; command, I added an action that stores the radio station URL as a variable called &quot;nowplaying&quot;. This allows VC to &quot;know&quot; what station is currently playing. Then we can use that variable in other commands -- to scrape the correct station to find out what song is playing, and here, we use the now playing variable to look up the associated radio station name from your&quot;internet radio stations&quot;  payload XML file.">
    <action>
      <cmdType>PayloadXML.GetPhrase</cmdType>
      <params>
        <param>net radio payloads\internet radio stations.xml</param>
        <param>{var.nowplaying}</param>
        <param>Random</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>This is {LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>This is {LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>What station is this, Name this station</phrase>
  </command>
</commandGroup>

If you haven't yet done so, I highly recommend that you watch the 2 "Editing & Building Commands" video tutorials. http://voxcommando.com/mediawiki/index.php?title=Video_Tutorials#Core_Concepts

Or if you've already watched those, perhaps re-watch them after reviewing my comments in the attached commands. Payloads are powerful and important tools in VoxCommando -- central to how it functions. It's important to genuinely understand how they work.
Title: Re: Internet Radio
Post by: nime5ter on October 03, 2014, 10:33:43 PM
By the way, to attach files to a post, you can click on "Additional Options" below the post field. There you'll see an Attach: "Choose File" option.
Title: Re: Internet Radio
Post by: lja on October 04, 2014, 12:41:25 AM
By the way, to attach files to a post, you can click on "Additional Options" below the post field. There you'll see an Attach: "Choose File" option.

Thanks. I missed that.
Title: Re: Internet Radio
Post by: lja on October 04, 2014, 12:57:06 AM
Re Reply #69

@Nime5ter. Thanks. Works nicely. Will again review videos. In the interim I have a question. Based on your notes, am I correct that only stations of the same as in shoutcast will work as per your code? In other words, a station like radio paradise would not work if added to the payload. However other shoutcast stations could be added and will work. Thanks.
Title: Re: Internet Radio
Post by: nime5ter on October 04, 2014, 08:28:42 AM
Yes, that's what I indicated -- but mainly this has to do with the "get song info" command. That command scrapes the Shoutcast stream URL to retrieve song information. Since different sites work differently, that command will not work for Radio Paradise.

However, you could still add the Radio Paradise stream's URL (http://stream-tx4.radioparadise.com:80/mp3-128) to your payload XML file and issue the command to listen to Radio Paradise.

The command asking "What station is this" will also work, because it is not trying to scrape a website; it is looking up that information locally, in your payload XML file.

In theory, you could add a separate command to get the song info for Radio Paradise (using the xml that James has posted previously) -- just make sure to make the phrasing unique in order to distinguish that query from the one you're using for the Shoutcast stations.
Title: Re: Internet Radio
Post by: lja on October 04, 2014, 05:27:49 PM

Thanks.