A search query for web radios
This code makes a request to the known site www.shoutcast.com for web radios.it have more 57000 free internet radio stations.
can enter a name of artist , a genre,....
the site returns a list of radios working with the query introduced.
for ex for Beethoven i obtain 39 listed results
for Bach...more 140 listed results...
Each result of the list have a link to play the radio.i retained only the m3u whose is with association of windows mediaplayer (and cut winamp and XSPF).
on click the wmp fires and link to the specified radio.
(can adjust the wmp visualization(animation is saved and wmp restores the last one played).
the wmp classic toolbar appears also).
Each result is shown with station,genre,listeners,bitrate and type).
can adjust the window contextmenu on or off (its on to copy the radio URL...print..).
Application procedure:
stay some seconds to see the string searched on textbox and then click on search right button (I cannot found a solution to automate it...).
When the results appear then click the bottom button to fire the window of results. ;
I set the timer interval to 5sec..if internet is fast can decrease it!.
As usual internet must be connected to make the code working (can add test as previous posts)
can build a proj (add a config.fpw) and compile to an exe.
Important:this code was tested on win10 pro+vfp9sp2 and ie11 emulation.
*Update:
*the second code is an update of the first one.Automation problem solved.code might be controlled from vfp.
Click on code to select [then copy] -click outside to deselect
*1*
Set Safe Off
Publi oform
oform=Newobject("yradios")
oform.Show
Read Events
Retu
*
Define Class yradios As Form
BorderStyle = 0
Height = 250
Width = 920
ShowWindow = 2
AutoCenter = .T.
Caption = "Search for web radios on shoutcast.com"
MaxButton = .F.
BackColor = Rgb(0,0,0)
xs = .F.
Add Object olecontrol1 As OleControl With ;
oleclass="shell.explorer.2", ;
Top = -168, ;
Left = 0, ;
Height = 360, ;
Width = 920, ;
Name = "Olecontrol1"
Add Object command1 As CommandButton With ;
Top = 204, ;
Left = 336, ;
Height = 37, ;
Width = 300, ;
FontBold = .T., ;
FontSize = 10, ;
Caption = "Click search button+view results when done!", ;
MousePointer = 15, ;
ForeColor = Rgb(128,0,64), ;
BackColor = Rgb(128,255,0), ;
Name = "Command1"
Add Object timer1 As Timer With ;
Top = 204, ;
Left = 648, ;
Height = 23, ;
Width = 23, ;
Enabled = .F., ;
Interval = 5000, ;
Name = "Timer1"
Add Object optiongroup1 As OptionGroup With ;
AutoSize = .T., ;
ButtonCount = 1, ;
BackStyle = 0, ;
Value = 1, ;
Height = 27, ;
Left = 696, ;
Top = 204, ;
Width = 104, ;
Name = "Optiongroup1", ;
Option1.BackStyle = 0, ;
Option1.Caption = "Context menu", ;
Option1.Value = 1, ;
Option1.Height = 17, ;
Option1.Left = 5, ;
Option1.Top = 5, ;
Option1.Width = 94, ;
Option1.AutoSize = .T., ;
Option1.ForeColor = Rgb(255,255,255), ;
Option1.Name = "Option1"
Procedure Destroy
Erase (Addbs(Sys(2023))+ "yradios.html") &&clean
Clea Events
Endproc
Procedure Load
Declare Integer Sleep In kernel32 Integer
Endproc
Procedure Init
Thisform.timer1.Enabled=.T.
Endproc
Procedure olecontrol1.Init
This.silent=.T.
Thisform.xs=Inputbox("Search radio...enter a string!","","BeetHoven")
This.Navigate("http://www.shoutcast.com/Search")
Endproc
Procedure command1.Init
This.Enabled=.F.
Endproc
Procedure command1.Click
This.Visible=.F.
Local m.x,m.result
With Thisform.olecontrol1
result=.Document.getElementById("nb-result").innertext
Local m.str
m.str=Iif(Thisform.optiongroup1.Value=1,"retun true;"," return false;")
TEXT to m.x textmerge noshow
<style>
table, th, td {
border: 0px solid maroon;
border-collapse: collapse;
border-spacing: 2px;
}
tr:nth-of-type(odd) {background-color:#C9FF93;}
</style>
<script type="text/javascript">
function yhelp(){
var x='This code makes a request to the site www.shoutcast.com for web radios. \n' +
'can enter a name of artist , a genre,....'+
'the site returns a list of radios working with the query introduced. \n'+
'for ex for Beethoven i obtain 39 results \n'+
'for Bach...more 140 results... \n'+
'Each result of the list have a link to play the radio.i retained only the m3u whose is \n '+
'with association of windows mediaplayer.on click the wmp fires and link to the specified radio. \n'+
'(can adjust the wmp visualization.the wmp toolbar appears also). \n'+
'Each result is shown with station,genre,listeners;bitrate and type). \n'+
'can adjust the window contextmenu on or off (on to copy the radio URL...print..). \n \n'+
'procedure: \n'+
'stay some seconds to see the string searched on textbox and then click on search right button \n'+
'When the results appear then click the bottom button to fire the window of results. \n';+
'I set the timer interval to 5sec..if internet is fast can decrease it!.'
alert(x);
}
</script>
<BODY OnContextmenu="<<m.str>>" scroll="yes">
<table width="<<thisform.olecontrol1.width-40>>" >
<tr><td><img src="http://findicons.com/files/icons/725/colobrush/128/firefox.png" title="Summary help" style="cursor:pointer;" width="64" height="64" onclick="yhelp();"> </td>
<td> <center><h2 style="color:red;"> -<<trans(m.result)>>-</h2></center></td> </tr>
</table>
<center><p style="font:small;font-bold;background-color:lime;">M3U is playlist for windows mediaplayer- [Click the left link to play radio.Click the fox icon to see help]-powered by Shoutcast.com </p></center>
ENDTEXT
m.x=m.x+"<center><table>"+Strextract(.Document.getElementById("station-list").innerhtml ,"<thead>","</tbody>",1) +"</table></center>"
m.x=Strtran(m.x,"XSPF","")
m.x=Strtran(m.x,"Winamp","")
m.lcdest=Addbs(Sys(2023))+ "yradios.html"
Strtofile(m.x,m.lcdest)
.Navigate(m.lcdest)
.Top=0
.Height=600
.Parent.Height=600
.Parent.AutoCenter=.T.
Endwith
Endproc
Procedure timer1.Timer
Thisform.olecontrol1.Document.getElementById("search-focus").Value=Thisform.xs
This.Enabled=.F.
Thisform.command1.Enabled=.T.
Endproc
Enddefine
*
*-- EndDefine: YRADIOS
can close the form and stay the wmp radio playing.if enable context menu can pick the url of the station .the site have an API but recquires a Key to work...
Click on code to select [then copy] -click outside to deselect
![]()
*2* added on wednesday 02 december 2015 *this is an update of the *1* code .Automation problems are solved and the code is controlled from vfp. *this works:Thisform.olecontrol1.Document.getElementById("search-form").submit("") *this dont work:Thisform.olecontrol1.Document.getElementById("search-form").submit() * if ! _vfp.startmode=0 on shutdown quit endi Publi yform yform=Newobject("yradios") yform.Show Read Events Retu Define Class yradios As Form BorderStyle = 0 Height = 173 Width = 920 ShowWindow = 2 ShowTips = .T. AutoCenter = .T. Caption = "Search for web radios on shoutcast.com" MaxButton = .F. BackColor = Rgb(0,0,0) xs = .F. Add Object olecontrol1 As OleControl With ; Oleclass="shell.explorer.2", ; Top = -252, ; Left = -12, ; Height = 360, ; Width = 928, ; Name = "Olecontrol1" Add Object command1 As CommandButton With ; Top = 132, ; Left = 415, ; Height = 34, ; Width = 300, ; FontBold = .T., ; FontSize = 10, ; Caption = "Click search button+view results when done!", ; MousePointer = 15, ; SpecialEffect = 2, ; ForeColor = Rgb(128,0,64), ; BackColor = Rgb(255,128,0), ; Name = "Command1" Add Object timer1 As Timer With ; Top = 120, ; Left = 504, ; Height = 23, ; Width = 23, ; Enabled = .F., ; Interval = 5000, ; Name = "Timer1" Add Object optiongroup1 As OptionGroup With ; AutoSize = .T., ; ButtonCount = 1, ; BackStyle = 0, ; Value = 1, ; Height = 27, ; Left = 743, ; SpecialEffect = 0, ; Top = 135, ; Width = 104, ; Name = "Optiongroup1", ; Option1.BackStyle = 0, ; Option1.Caption = "Context menu", ; Option1.Value = 1, ; Option1.Height = 17, ; Option1.Left = 5, ; Option1.ToolTipText = "On/oFF", ; Option1.Top = 5, ; Option1.Width = 94, ; Option1.AutoSize = .T., ; Option1.ForeColor = Rgb(255,255,255), ; Option1.Name = "Option1" Add Object command3 As CommandButton With ; Top = 133, ; Left = 247, ; Height = 34, ; Width = 132, ; FontBold = .T., ; FontSize = 11, ; Caption = "Search ....", ; Default=.t., ; Enabled = .F., ; MousePointer = 15, ; SpecialEffect = 2, ; ForeColor = Rgb(255,0,0), ; BackColor = Rgb(128,255,0), ; Name = "Command3" Add Object text1 As TextBox With ; FontBold = .T., ; FontSize = 12, ; BorderStyle = 0, ; Value = "Bach", ; Height = 34, ; Left = 2, ; ToolTipText = "Enter artist, genre...to search for", ; Top = 134, ; Width = 240, ; ForeColor = Rgb(255,0,0), ; Name = "Text1" Procedure Load Declare Integer Sleep In kernel32 Integer Endproc Procedure Init Thisform.timer1.Enabled=.T. Endproc Procedure Destroy Erase (Addbs(Sys(2023))+ "yradios.html") Clea Events Endproc Procedure olecontrol1.Init This.silent=.T. Thisform.xs="" This.Navigate("http://www.shoutcast.com/Search") Endproc Procedure command1.Click This.Visible=.F. Local m.x,m.result With Thisform.olecontrol1 result=.Document.getElementById("nb-result").innertext Local m.str m.str=Iif(Thisform.optiongroup1.Value=1,"retun true;"," return false;") TEXT to m.x textmerge noshow <style> table, th, td { border: 0px solid maroon; border-collapse: collapse; border-spacing: 2px; } tr:nth-of-type(odd) {background-color:#C9FF93;} </style> <script type="text/javascript"> function yhelp(){ var x='This code makes a request to the site www.shoutcast.com for web radios. \n' + 'can enter a name of artist , a genre,....'+ 'the site returns a list of radios working with the query introduced. \n'+ 'for ex for Beethoven i obtain 39 results \n'+ 'for Bach...more 140 results... \n'+ 'Each result of the list have a link to play the radio.i retained only the m3u whose is \n '+ 'with association of windows mediaplayer.on click the wmp fires and link to the specified radio. \n'+ '(can adjust the wmp visualization.the wmp toolbar appears also). \n'+ 'Each result is shown with station,genre,listeners;bitrate and type). \n'+ 'can adjust the window contextmenu on or off (on to copy the radio URL...print..). \n \n'+ 'procedure: \n'+ 'Input the string to search in textbox,click the search button. \n'+ 'When the results appear then click the right button to fire the window of results. \n';+ 'I set the timer interval to 5sec..if internet is fast can decrease it!.' alert(x); } </script> <BODY OnContextmenu="<<m.str>>" scroll="yes"> <table width="<<thisform.olecontrol1.width-40>>" > <tr><td><img src="http://findicons.com/files/icons/725/colobrush/128/firefox.png" title="Summary help" style="cursor:pointer;" width="64" height="64" onclick="yhelp();"> </td> <td> <center><h2 style="color:red;"> -<<trans(m.result)>>-</h2></center></td> </tr> </table> <center><p style="font:small;font-bold;background-color:lime;">M3U is playlist for windows mediaplayer- [Click the left link to play radio.Click the fox icon to see help]-powered by Shoutcast.com </p></center> ENDTEXT m.x=m.x+"<center><table>"+Strextract(.Document.getElementById("station-list").innerhtml ,"<thead>","</tbody>",1) +"</table></center>" m.x=Strtran(m.x,"XSPF","") m.x=Strtran(m.x,"Winamp","") m.lcdest=Addbs(Sys(2023))+ "yradios.html" Strtofile(m.x,m.lcdest) .Navigate(m.lcdest) .Top=0 .Height=600 .Parent.Height=600 .Parent.AutoCenter=.T. Endwith Endproc Procedure command1.Init This.Enabled=.F. Endproc Procedure timer1.Timer Thisform.olecontrol1.Document.getElementById("search-focus").Value=Thisform.xs This.Enabled=.F. Thisform.command1.Enabled=.T. Thisform.command3.Enabled=.T. Endproc Procedure command3.Click Thisform.xs=Allt(Thisform.text1.Value) Thisform.olecontrol1.Document.getElementById("search-focus").Value=Thisform.xs Sleep(500) Thisform.olecontrol1.Document.getElementById("search-form").submit("") Endproc Enddefine * *-- EndDefine: yradios