diff options
author | TheTroll <trolldev@gmail.com> | 2010-03-24 17:40:22 +0100 |
---|---|---|
committer | TheTroll <trolldev@gmail.com> | 2010-03-24 17:40:22 +0100 |
commit | 50c89b73b4f8e3e4b86dcac9865ee96931c7a9b4 (patch) | |
tree | c0c62ffc767fb791eb57f173a4ade020dd80951a /bin | |
parent | 9a1a60cd639222e20564eef754d69abfdc761e20 (diff) | |
download | istreamdev-50c89b73b4f8e3e4b86dcac9865ee96931c7a9b4.tar.gz istreamdev-50c89b73b4f8e3e4b86dcac9865ee96931c7a9b4.tar.bz2 |
Added getepg and getepginfo
Diffstat (limited to 'bin')
-rwxr-xr-x[-rw-r--r--] | bin/auth.php | 0 | ||||
-rwxr-xr-x | bin/backend.php | 9 | ||||
-rwxr-xr-x[-rw-r--r--] | bin/genmanifest.php | 0 | ||||
-rwxr-xr-x | bin/jsonapi.php | 18 | ||||
-rwxr-xr-x | bin/session.php | 4 | ||||
-rwxr-xr-x | bin/vdr.php | 88 |
6 files changed, 109 insertions, 10 deletions
diff --git a/bin/auth.php b/bin/auth.php index 7e6eace..7e6eace 100644..100755 --- a/bin/auth.php +++ b/bin/auth.php diff --git a/bin/backend.php b/bin/backend.php index 706dd91..ad72df7 100755 --- a/bin/backend.php +++ b/bin/backend.php @@ -100,6 +100,15 @@ switch ($action) $tree = streamAudio($_REQUEST['path'], $_REQUEST['file']); print $tree; break; + + case ("getEpg"): + $tree = getEpg($_REQUEST['channel'], $_REQUEST['time'], $_REQUEST['day'], $_REQUEST['programs']); + print $tree; + break; + case ("getEpgInfo"): + $tree = getEpgInfo($_REQUEST['channel'], $_REQUEST['time'], $_REQUEST['day']); + print $tree; + break; } ?> diff --git a/bin/genmanifest.php b/bin/genmanifest.php index 26981c4..26981c4 100644..100755 --- a/bin/genmanifest.php +++ b/bin/genmanifest.php diff --git a/bin/jsonapi.php b/bin/jsonapi.php index a567808..298806b 100755 --- a/bin/jsonapi.php +++ b/bin/jsonapi.php @@ -188,4 +188,22 @@ function streamAudio($path, $file) } +function getEpg($channel, $time, $day, $programs) +{ + $ret = array(); + + $ret['channel'] = vdrgetepg($channel, $time, $day, $programs, 0); + + return json_encode($ret); +} + +function getEpgInfo($channel, $time, $day) +{ + $ret = array(); + + $ret['program'] = vdrgetepg($channel, $time, $day, 1, 1); + + return json_encode($ret); +} + ?> diff --git a/bin/session.php b/bin/session.php index 144b8da..0819632 100755 --- a/bin/session.php +++ b/bin/session.php @@ -142,8 +142,8 @@ function sessiongetinfo($session) case 'tv': $info['name'] = $channame; $channum = vdrgetchannum($channame); - list($info['now_time'], $info['now_title'], $info['now_desc']) = vdrgetchanepg($channum, 1); - list($info['next_time'], $info['next_title'], $info['next_desc']) = vdrgetchanepg($channum, 0); + list($info['now_time'], $info['now_title'], $info['now_desc']) = vdrgetchanat($channum, "now"); + list($info['next_time'], $info['next_title'], $info['next_desc']) = vdrgetchanat($channum, "next"); break; case 'rec': $info['channel'] = $channame; diff --git a/bin/vdr.php b/bin/vdr.php index 751ae32..89f4f1d 100755 --- a/bin/vdr.php +++ b/bin/vdr.php @@ -236,18 +236,15 @@ function vdrgetchaninfo($channum) $info['name'] = vdrgetchanname($channum); $info['number'] = $channum; - list($info['now_time'], $info['now_title'], $info['now_desc']) = vdrgetchanepg($channum, 1); - list($info['next_time'], $info['next_title'], $info['next_desc']) = vdrgetchanepg($channum, 0); + list($info['now_time'], $info['now_title'], $info['now_desc']) = vdrgetchanat($channum, "now"); + list($info['next_time'], $info['next_title'], $info['next_desc']) = vdrgetchanat($channum, "next"); return $info; } -function vdrgetchanepg($channum, $now) +function vdrgetchanat($channum, $at) { - if ($now) - $cmd = "LSTE " .$channum ." NOW"; - else - $cmd = "LSTE " .$channum ." NEXT"; + $cmd = "LSTE " .$channum ." " .$at; $epg = vdrsendcommand($cmd); @@ -269,6 +266,9 @@ function vdrgetchanepg($channum, $now) $timearray = explode(" ", $time); $time = date('H\hi', $timearray[1]) ."-" .date('H\hi', $timearray[1]+$timearray[2]); + $endtime = $timearray[1]+$timearray[2]; + + $date = date('Y\/m\/d', $timearray[1]); } } @@ -278,7 +278,79 @@ function vdrgetchanepg($channum, $now) if (!is_utf8($desc)) $desc = utf8_encode($desc); - return array($time, $title, $desc); + return array($date, $time, $title, $desc, $endtime); +} + +function vdrgetchanepg($channame, $channum, $chancat, $time, $programs, $extended) +{ + + // Create a new chan entry in epg + $chanentry = array(); + $chanentry['name'] = $channame; + $chanentry['number'] = $channum; + $chanentry['category'] = $chancat; + $chanentry['epg']= array(); + + $attime = $time; + $nbepg = 0; + + $chanepg = array(); + do + { + if (!$extended) + list ($date, $chanepg['time'], $chanepg['title'], $desc, $endtime) = vdrgetchanat($channum, "at " .$attime); + else + list ($chanepg['date'], $chanepg['time'], $chanepg['title'], $chanepg['desc'], $endtime) = vdrgetchanat($channum, "at " .$attime); + $chanentry['epg'][] = $chanepg; + + $attime = $endtime+1; + $nbepg++; + } + while ($nbepg < $programs); + + return $chanentry; +} + +function vdrgetepg($channel, $time, $day, $programs, $extended) +{ + $epgout = array(); + + // Compute time + $currentdate = gettimeofday(); + + // Remove current day minutes + $currentday = $currentdate['sec'] - ($currentdate['sec'] % (3600*24)); + + $requestedhours = (int) substr($time, 0, 2); + $requestedmins = (int) substr($time, 2); + $requestedtime = ($requestedhours * 3600) + ($requestedmins * 60); + + // Comput requested date + $requesteddate = $currentday + ((int)$day * (3600*24)) + $requestedtime - 3600; + + // Get epg + if ($channel == all) + { + // Get all categories + $categories = vdrgetcategories(); + + // For all categories + $catcount = count($categories); + for ($i = 0; $i < $catcount; $i++) + { + // Get all channels + $channels = vdrgetchannels($categories[$i]['name'], 0); + + // For all channels + $chancount = count($channels); + for ($j = 0; $j < $chancount; $j++) + $epgout[] = vdrgetchanepg($channels[$j]['name'], $channels[$j]['number'], $categories[$i]['name'], $requesteddate, $programs, 0); + } + } + else + $epgout[] = vdrgetchanepg(vdrgetchanname($channel), $channel, "Unknown", $requesteddate, $programs, $extended); + + return $epgout; } function vdrgetrecinfo($rec) |