Last modified at 11/2/2013 11:24 AM by Koen Zomers

The DreamBox 500 webinterface keeps polling /data every few seconds to retrieve actual information from the DreamBox. It actually returns a piece of HTML with JavaScript. In the JavaScript there's a whole list with very interesting data you could easily use in your own applications. Otherwhise you would have to perform multiple HTTP calls to the DreamBox to get the same information where you can now get it using one HTTP request. Using a regular expression you can easily fetch out the data you need.

Calling http://<address of your dreambox>/data returns a result similar to:

<html>
<head>
<script type="text/javascript">
function update()
{
 if (parent.headerUpdateEPGData)
  parent.headerUpdateEPGData(serviceName, nowT, nowD, nowSt, nextT, nextD, nextSt);
 if (parent.headerUpdateStatusBar)
  parent.headerUpdateStatusBar(vpid, apid, ip, lock, upTime, agc, snr, ber);
 if (parent.headerUpdateVolumeBar)
  parent.headerUpdateVolumeBar(volume, mute);
 if (parent.headerUpdateChannelStatusBar)
  parent.headerUpdateChannelStatusBar(dolby, crypt, format);
 if (parent.headerUpdateRecording)
  parent.headerUpdateRecording(recording);
 if (parent.updateVideoBar)
  parent.updateVideoBar(videoPosition, videoTime, diskGB, diskH);
}
</script>
</head>
<body onLoad="update()">
<script>
 <!-- variables set by box -->
 var updateCycleTime = 10000;
 <!-- power state -->
 var standby = 0;
 <!-- service & epg data -->
 var serviceName = "Veronica/Disney XD";
 var nowT = "20:30";
 var nowD = "(65)";
 var nowSt = "Hawaii Five-O";
 var nextT = "21:35";
 var nextD = "(50)";
 var nextSt = "NCIS Los Angeles";
 <!-- status bar -->
 var diskGB = "0 MB";
 var diskH = "~0 min";
 var apid = "0x1f5";
 var vpid = "0x39";
 var ip = "<removed>";
 var lock = "locked";
 var upTime = "0:04 h up";
 <!-- volume bar -->
 var volume = 37;
 var mute = 0;
 <!-- channel stats -->
 var dolby = 0;
 var crypt = 1;
 var format = 1;
 <!-- recording -->
 var recording = 0;
 <!-- vlc streaming -->
 var vlcparms = "http://<removed>:31339/0,044c,0039,01f5";
 var serviceReference = "1:0:1:2af9:b:3e8:ffff0000:0:0:0:";
 var videoTime = "0:00";
 var videoPosition = 0;
 <!-- stream info -->
 var agc = 41;
 var snr = 93;
 var ber = 0;
 <!-- streaming client status -->
 var streamingClientStatus = 2147048016;
</script>
</body>
</html>

A regular expression like the following pulls some of the information out of this result. You can of course adjust it to your specific needs:

.*?var serviceName = "(?<channelName>.*?)".*?var nowT = "(?<currentProgramStartedAt>.*?)".*?var nowSt = "(?<currentProgramName>.*?)".*?var nextT = "(?<nextProgramStartsAt>.*?)".*?var nextSt = "(?<nextProgramName>.*?)".*?var volume = (?<volume>\d{1,2}).*?var mute = (?<mute>[01]).*?var crypt = (?<channelEncrypted>[01]).*?var serviceReference = "(?<channelServiceReference>.*?)".*?

This Regex created named capture groups of some of the information mentioned in the JavaScript var declarations. Using a piece of code you can easily retrieve the values from the named capture groups and use them in your own application.