Quick hack to generate xmltv listings from TVxb style .ini files.
*/
+// seriously it's this bad..
+error_reporting(E_ALL & ~E_STRICT &~E_NOTICE);
+
+
if (!extension_loaded('mbstring')) {
// kludge. = first monday of current week..
// loook for... <BR>2007-12-31 Mon
$start = preg_match('/<BR>([0-9]{4}-[0-9]{2}-[0-9]{2}) Mon/i', $odata, $matches);
- $start = $matches[1]; // first monday..
+ $start = isset($matches[1]) ? $matches[1] : 0; // first monday..
+
+ $use_cols = 1;
foreach($days as $i=>$ddata) {
+
+
+
$cols = explode(',',$cinfo['htmlcols']);
- $dn = strtotime($start) + (($i ) * 24 * 60 * 60 );
- $this->schedule[$chid][strtotime($start) + (($i ) * 24 * 60 * 60 )] = $this->$method($ddata,$cols,date('Y-m-d',$dn));
+ $dn = strtotime($start) + (($i * $use_cols) * 24 * 60 * 60 );
+ $res = $this->$method($ddata,$cols,date('Y-m-d',$dn));
+ if (is_string($res)) {
+ $start = $res;
+ $use_cols =0;
+ continue;
+ }
+ if (!is_array($res)) {
+ continue;
+ }
+ $day_id = strtotime($start) + (($i * $use_cols ) * 24 * 60 * 60 );
+
+ //print_r($res);
+
+ if (empty($this->schedule[$chid][$day_id])) {
+ $this->schedule[$chid][$day_id] = array();
+ }
+ $this->schedule[$chid][$day_id] = array_merge($this->schedule[$chid][$day_id], $res);
}
return;
}
- function parseJade($data, $colnames)
+ function parseJade($data, $colnames, $day=0)
{
$rows = preg_split('#</li>#i', $data);
$r = str_ireplace(' ',' ', $r);
$rdata = array();
- list($time,$r) = explode('</span>', $r, 2);
+ @list($time,$r) = explode('</span>', $r, 2);
$rdata['hour'] = trim(strip_tags($time));
if (!strlen($rdata['hour'])) {
// if it's a day row..
- if (preg_match('/<div/', trim($data))) {
- preg_match('/<BR>([0-9]{4}-[0-9]{2}-[0-9]{2})/i', $data, $matches);
- return $matches[1];
+ $lines = explode("\n", trim($data));
+ //var_dump($lines[1]);
+
+
+ if (isset($lines[1]) && preg_match('/<div/', trim($lines[1]))) {
+
+ preg_match('/<BR>([0-9]{4}-[0-9]{2}-[0-9]{2})/i', $lines[1], $matches);
+ //var_dump($matches[1]);
+ return $matches[1];
}
$rows = preg_split('/<tr[^>]*>/i', $data);
- $this->debug(print_r($rows,true));
- return;
+ if ($day == '2011-10-29') {
+ //$this->debug(print_r($rows,true));
+ }
+ if ($day < date('Y-m-d')) {
+ // $this->debug("OLD DATA $day");
+ return array();
+ }
+ //$this->debug($day);
+ //$this->debug(print_r($rows,true));
+ //return;
array_shift($rows);
-
- $day = false;
+ $ret = array();
+ //$day = false;
foreach($rows as $r) {
//print_r($r);
$cols = preg_split('/<td[^>]*>/i', $r);
$rdata = array();
-
+ if (!isset($cols[2])) {
+ continue;
+ }
//PRINT_r($cols);
$c= $cols[2];
//var_dump($c);
if (!preg_match('/^[0-9]+:[0-9]+/', $c)) {
continue;
}
-
- $rdata['time'] = trim(array_shift(explode('<', $c)));
+ //$this->debug("GOT HOUR: $c");
+ $rdata['hour'] = trim(array_shift(explode('<', $c)));
$c = $cols[3];
$kv = preg_split('/<br>/',$c);
- $c = $kv[1];
+ $c = isset($kv[1]) ? $kv[1] : '';
$c = str_ireplace('<br>',' ', $c);
$c = str_ireplace(' ',' ', $c);
$c = str_replace("\n",' ', $c);
$rdata['day'] = $day;
- print_R($rdata);
+ //print_R($rdata);
$ret[] = $rdata;
}
//print_r($ret); exit;
continue;
}
foreach($sched as $item) {
- //print_r($item);
+ $item['day'] = $day;
+
$bits = explode(':', $item['hour']);
if ($bits[0] < $last) {
$hoffset +=12;
}
$last = $bits[0];
+
//var_dump($bits[0] + $hoffset);
$start = mktime(/*hmsmdy */
$bits[0] + $hoffset,
date('d', $day),
date('Y', $day)
);
-
+ if ($start < strtotime(date("Y-m-d 00:00:00", strtotime('NOW - 1 DAY')))) {
+ continue;
+ }
+ $item['hoffset'] = $hoffset;
+ $item['hoffset_ar'] = $bits;
+
+ //$this->debug(print_r($item, true));
$start_str = date('YmdHis',$start) . ' ' . $this->config['gmtoffset'];
//var_dump($start_str);
//var_dump($this->channels);
$description = iconv($this->channels[$chan]['encoding'], 'UTF-8',$item['description'] .
(isset($item['description2']) ? (' ' . $item['description2']) : ''));
+ $this->debug(date("Y-m-d H:i - ", $start). $description);
+
+
$pg = $doc->createElement('programme');
$pg->setAttribute('channel', $chan);
{
// remove sponsor message.
$title_pre = '';
- list($title, $fuldesc) = explode(">>",$description);
+ @list($title, $fuldesc) = explode(">>",$description);