diff options
author | TheTroll <trolldev@gmail.com> | 2010-03-17 22:42:06 +0100 |
---|---|---|
committer | TheTroll <trolldev@gmail.com> | 2010-03-17 22:42:06 +0100 |
commit | d0640763e648d441510afeb5939106eb8d48731c (patch) | |
tree | f8542d1329646a3968ee8e6cf4640af103ee8aa6 /bin | |
parent | 56cb9c5e115fcf9f6e732d2b2cc95afff66c90ac (diff) | |
download | istreamdev-d0640763e648d441510afeb5939106eb8d48731c.tar.gz istreamdev-d0640763e648d441510afeb5939106eb8d48731c.tar.bz2 |
Timers WIP
Added getID3
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/backend.php | 30 | ||||
-rwxr-xr-x | bin/jsonapi.php | 18 | ||||
-rwxr-xr-x | bin/vdr.php | 332 |
3 files changed, 60 insertions, 320 deletions
diff --git a/bin/backend.php b/bin/backend.php index 87a5f7b..8619c89 100755 --- a/bin/backend.php +++ b/bin/backend.php @@ -91,25 +91,23 @@ switch ($action) break; case ("getTimers"): - $tree = file_get_contents("textfiles/getTimers.txt"); - print $tree; - break; + $tree = getTimers(); + print $tree; + break; case ("editTimer"): - $id = $_REQUEST['id']; - if (id) { - $tree = file_get_contents("textfiles/editTimer.txt"); - } - else { - $tree = file_get_contents("textfiles/addTimer.txt"); - } - print $tree; - break; + $id = $_REQUEST['id']; + if (id) + $tree = file_get_contents("textfiles/editTimer.txt"); + else + $tree = file_get_contents("textfiles/addTimer.txt"); + print $tree; + break; - case ("deltimer"): - $tree = file_get_contents("textfiles/delTimer.txt"); - print $tree; - break; + case ("delTimer"): + $tree = delTimer($_REQUEST['id']); + print $tree; + break; case ("browseFolder"): $path = $_REQUEST['path']; diff --git a/bin/jsonapi.php b/bin/jsonapi.php index 0f922c2..8f144d9 100755 --- a/bin/jsonapi.php +++ b/bin/jsonapi.php @@ -126,6 +126,24 @@ function getStreamStatus($session) return json_encode($ret); } +function getTimers() +{ + $ret = array(); + + $ret['timer'] = vdrlisttimers(); + + return json_encode($ret); +} + +function delTimer($id) +{ + $ret = vdrdeltimer($id); + + return json_encode($ret); +} + + + function getRunningSessions() { $ret = array(); diff --git a/bin/vdr.php b/bin/vdr.php index 760e4f6..d0df102 100755 --- a/bin/vdr.php +++ b/bin/vdr.php @@ -324,294 +324,16 @@ function vdrgetrecinfo($rec) return array($channame, $epgtitle, $epgdesc, $recorded); } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function vdrgetinfostream($stream = "NULL", $ischan = 1) -{ - global $allepg, $allepgfilled; - $stream=stripslashes($stream); - if ($ischan) - { - // Fill epg if not yet done - if ($allepgfilled == 0) - { - $allepg = vdrsendcommand("LSTE NOW"); - $allepgfilled = 1; - } - - $channame = $stream; - } - else - { - $infofile = $stream ."/info"; - if (file_exists($infofile)) - $info= file_get_contents($infofile); - else - { - $infofile = $stream ."/info.vdr"; - if (file_exists($infofile)) - $info= file_get_contents($infofile); - else - $info=""; - } - - $allepg = explode("\n", $info); - } - - if ($ischan) - $chanfound = 0; - else - $chanfound = 1; - $epgtitlefound = 0; - - $epgtitle=""; - $epgdesc=""; - - // For all epg - $count = count($allepg); - for ($i = 0; $i < $count; $i++) - { - // Find the right chan (take the first one) - if ($chanfound == 0) - { - $streamArray = explode(";",$stream); - if (strstr($allepg[$i], $streamArray[0]) == $streamArray[0]) - $chanfound = 1; - } - else - { - // Now find T or C - if(ereg("^C", $allepg[$i])) - { - // Check if it is our chan too, else search again - if ($ischan) - { - if(!ereg("$stream$", $allepg[$i])) - { - $chanfound = 0; - continue; - } - } - else - { - $channame = substr($allepg[$i], 2); - $channames = explode(" ", $channame); - $channame = substr($channame, strlen($channames[0])+1); - } - } - else if(ereg("^T", $allepg[$i])) - $epgtitle=substr($allepg[$i], 2); - else if(ereg("^D", $allepg[$i])) - $epgdesc=substr($allepg[$i], 2); - } - } - - // Convert if needed - if (!is_utf8($epgtitle)) - $epgtitle = utf8_encode($epgtitle); - if (!is_utf8($epgdesc)) - $epgdesc = utf8_encode($epgdesc); - - - return array($epgtitle, $epgdesc, $channame); -} - -function vdrgettimerinfo($timernum=-1) -{ - if ($timernum != -1) - { - $timer = vdrsendcommand("LSTT " .$timernum); - - $timerarray = explode(":", $timer); - - $typearray = explode(" ", $timerarray[0]); - $type = $typearray[1]; - $channel = $timerarray[1]; - $date = $timerarray[2]; - $stime = $timerarray[3]; - $etime = $timerarray[4]; - $desc = $timerarray[7]; - } - else - { - $type = 1; - $channel = 1; - $date = date('Y-m-d'); - $stime = date('Hi'); - $etime = date('Hi'); - $desc = "New timer"; - } - - $channame = vdrgetchanname($channel); - - return array($type, $channame, $date, $stime, $etime, $desc); -} - -function vdrlistchannels($category = "NULL") -{ - global $epgtitle; - global $vdrchannels; - - if ($category == "All") - $cat_found=1; - else - $cat_found=0; - - if (!file_exists($vdrchannels)) - { - print "Error: channels file not found"; - return; - } - - $fp = fopen ($vdrchannels,"r"); - if (!fp) - { - print "Unable to open channels file"; - return; - } - while ($line = fgets($fp, 1024)) - { - if ($cat_found) - { - if ($line[0] == ":") - { - if ($category == "All") - continue; - else - break; - } - - $channels = explode(":", $line); - $channels = explode(";", $channels[0]); - $chan = $channels[0]; - - // Get EPG title - $epgtitle = NULL; - list($epgtitle, $epgdesc, $channame) = vdrgetinfostream($chan, 1); - print "<li class=\"withimage\">"; - $chan2=addslashes($chan); - print " <a class=\"noeffect\" href=\"javascript:sendForm('$chan2');\">\r\n"; - $channoslash = preg_replace("$/$", " ", $chan); - if (!file_exists('logos/'.$channoslash.'.png')) - print " <img src=\"logos/nologoTV.png\" />\r\n"; - else - print " <img src=\"logos/{$channoslash}.png\" />\r\n"; - print " <span class=\"name\">$chan</span>\r\n"; - print " <span class=\"comment\">$epgtitle</span><span class=\"arrow\"></span></a>\r\n</li>\r\n"; - print " <form name=\"$chan\" id=\"$chan\" method=\"post\" action=\"index.php\">"; - print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"stream\" />"; - print " <input name=\"type\" type=\"hidden\" id=\"type\" value=1 />"; - print " <input name=\"name\" type=\"hidden\" id=\"name\" value=\"$chan\" />"; - print " </form>\r\n"; - } - else - { - if ($line[0] == ":") - { - // Remove : and @ - $cat = substr($line, 1, -1); - if($cat[0] == '@') - { - $cat_array = explode(' ', $cat); - $cat = substr($cat, strlen($cat_array[0])+1); - } - - // Check category - if ("$cat" == "$category") - $cat_found = 1; - } - } - } - fclose($fp); -} - -function vdrlistchannelsdrop($chansel = "") -{ - global $vdrchannels; - - $chanselected = 0; - - if (!file_exists($vdrchannels)) - { - print "Error: channels file not found"; - return; - } - - $fp = fopen ($vdrchannels,"r"); - if (!fp) - { - print "Unable to open channels file"; - return; - } - while ($line = fgets($fp, 1024)) - { - if ($line[0] == ":") - continue; - - $channels = explode(":", $line); - $channels = explode(";", $channels[0]); - $chan = $channels[0]; - if (($chan == $chansel) && !$chanselected) - { - print "<option selected value=\"{$chan}\">{$chan}</option>"; - $chanselected = 1; - } - else - print "<option value=\"{$chan}\">{$chan}</option>"; - } -} - function vdrlisttimers() { + $timerslist = array(); + $timers = vdrsendcommand("LSTT"); if (gettype($timers) == "string") { if (!is_numeric(substr($timers,0,1))) - { - print "<li class=\"textbox\"><p>none</p></li>\r\n"; - return; - } + return $timerslist; else $timersarray[] = $timers; } @@ -620,37 +342,39 @@ function vdrlisttimers() foreach($timersarray as $timer) { - // Extract timer # - $timerarray = explode(" ", $timer); - $timernum = $timerarray[0]; + $newtimer = array(); - list($type, $channame, $date, $starthour, $endhour, $desc) = vdrgettimerinfo($timernum); - - print "<li class=\"menu\">"; - print " <a href=\"javascript:sendForm('timer {$timernum}')\">\r\n"; - - if ($type & 0x8) - print " <img alt=\"list\" src=\"images/pictos/timerrec.png\" />\r\n"; - else if ($type & 0x1) - print " <img alt=\"list\" src=\"images/pictos/timeron.png\" />\r\n"; - else - print " <img alt=\"list\" src=\"images/pictos/timeroff.png\" />\r\n"; + // Extract timer info + $timerarray = explode(" ", $timer); - print " <span class=\"name\">{$date}: {$desc}</span><span class=\"arrow\"></span>\r\n"; + $newtimer['id'] = $timerarray[0]; - print " </a>\r\n"; - print "</li>\r\n"; + $timerarray = explode(":", $timer); - print "<form name=\"timer {$timernum}\" id=\"timer {$timernum}\" method=\"post\" action=\"index.php\">\r\n"; - print " <input name=\"action\" type=\"hidden\" id=\"action\" value=\"edittimer\"/>\r\n"; - print " <input name=\"timer\" type=\"hidden\" id=\"timer\" value=\"{$timernum}\" />\r\n"; - print "</form>\r\n"; + $typearray = explode(" ", $timerarray[0]); + $newtimer['name'] = $timerarray[7]; + $newtimer['active'] = (($typearray[1] & 0x1) != 0); + $newtimer['channumber'] = $timerarray[1]; + $newtimer['channame'] = vdrgetchanname($timerarray[1]); + $newtimer['date'] = $timerarray[2]; + $newtimer['starttime'] = $timerarray[3]; + $newtimer['endtime'] = $timerarray[4]; + $newtimer['running'] = (($typearray[1] & 0x8) != 0); + + $timerslist[] = $newtimer; } + + return $timerslist; } -function vdrdeltimer($timer=0) +function vdrdeltimer($timer) { - return vdrsendcommand("DELT " .$timer); + $ret = array(); + + $ret['status'] = "ok"; + $ret['message'] = vdrsendcommand("DELT " .$timer); + + return $ret; } function vdrsettimer($prevtimer, $channame, $date, $stime, $etime, $desc, $active) |