Author Topic: list presets in webby  (Read 827 times)

EastEriq

  • Full Member
  • ***
  • Posts: 37
  • Thanked: 2 times
  • OS:
  • Linux (Ubuntu) Linux (Ubuntu)
  • Browser:
  • Firefox 42.0 Firefox 42.0
list presets in webby
« on: 14:47:52 | 28 November, 2015 »
Small exercise, I don't know if there is still any interest for such stuff: drop this as /mnt/debug/webserver/cgi-bin/list_presets.cgi, chmod a+x, and get a tabular list of presets names and urls (IR) and FM frequencies with http://NN.NN.NN.NN/cgi-bin/list_presets.cgi . Works on my radio.

It would be appealing to transform this into a form interface allowing editing of these fields and rewrite of /root/config/preset*.xml and /root/config/fm_preset*.txt, but for the former I'm afraid the xml may require data better retrieved from the reciva server, like <streamid>.

Code: [Select]
#!/bin/ash
 
cd /root/config

echo -e "Content-Type text/html\r\n"

echo "<html>"
echo -e "<meta http-equiv=\"Content-Type\""
echo -e "content=\"text/html; charset=utf-8\"/>"
echo "<head> <title>Presets list</title>"
echo -e "<style type=\"text/css\">"
echo "table {border-collapse: collapse;}"
echo "td {border-top: 1px solid black; padding: 0.2em}"
echo "td.station {font-weight: bold}"
echo "</style>"

echo "</head><body>"

echo "<h1>Presets:</h1>"

IRPRESETS=`ls preset[0-9]*.xml|cut -c7-| cut -f1 -d"." |sort -n`

echo "<h2>Internet Radio</h2>"

echo "<table>"
echo "<tr><th>Preset</th><th>Name</th><th>URL</th></tr>"

for i in $IRPRESETS
do
    echo "<tr><td>$i</td>"
    echo "<td class="station">" `grep "title>" preset$i.xml | cut -f2 -d ">" | cut -f1 -d"<"` "</td>"
    STREAMURL=`grep "url>" preset$i.xml | cut -f4 -d ">" | cut -f1 -d"<"`
    echo -e "<td><a href=\"$STREAMURL\">" $STREAMURL "</a></td>"   
    echo "</tr>"
done
echo "</table>"

echo "<h2>FM</h2>"
                               
FMPRESETS=`ls fm_preset[0-9]*.txt|cut -c10-| cut -f1 -d"." |sort -n`

echo "<table>"
echo "<tr><th>Preset</th><th>kHz</th></tr>"         

for i in $FMPRESETS                                             
do                                                                             
      echo "<tr><td>$i</td>"
      FREQ=`tail +1 fm_preset$i.txt`       
      echo -e "<td>$FREQ</td>"               
      echo "</tr>"                                                               
done                                                                           
echo "</table>"                                                                 

echo "</body></html>"

ETA: leveraging on the existing naming mechanism for scripts in the webserver, if this script is saved as /mnt/debug/webserver/cgi-bin/radio_List_presets.cgi, a link to it will appear in the left column of the start page.
« Last Edit: 23:04:00 | 28 November, 2015 by EastEriq »

EastEriq

  • Full Member
  • ***
  • Posts: 37
  • Thanked: 2 times
  • OS:
  • Linux (Ubuntu) Linux (Ubuntu)
  • Browser:
  • Firefox 50.0 Firefox 50.0
Re: list presets in webby
« Reply #1 on: 00:42:08 | 23 January, 2017 »
I know it's a bit vane after all... This is how my latest presets management webby looks like. Code at https://github.com/philsmd/sharpfin/issues/50 .

 

anything