#!/usr/bin/php
<?php
$path = "/var/www/minerva/";
set_include_path(get_include_path() . PATH_SEPARATOR . $path);

require_once 'warp/applets/tvguide/progs.inc';
require_once 'warp/conf/tvguide/tvguide.conf';
require_once 'warp/conf/tvguide/users.conf';
require_once 'warp/conf/tvguide/channels.conf';

   // argv[1] = device. Unused, but kept for uniformity

   $channel = $argv[2];
   $detail = $argv[3];
   if($detail == "") {
      $detail = "name";
   }

   $u = Warp_TVGuide_Users::getUserGuide(0);
   $day = 0;	// currently, day[0] is always 'today' 

   $stations = Warp_TVGuide_Channels::getChannelList();
   $attime = date("Gi");
   $idx = 0;
   foreach($stations as $id => $name) {
      if ($idx == $channel) {
          $prog = $u->getDay($day)->getProgrammeAt($id, $attime);
          if ($prog->_name != "") {
              switch($detail) {
                case "name":
                   print $prog->_name;
                   break;
                case "info":
                   print $prog->_description;
                   break;
                case "timeon":
                   print $prog->_timeOn;
                   break;
                case "timeoff":
                   print $prog->_timeOff;
                   break;
               }
          }
       }
       ++$idx;
    }

?>

