header('Content-type: application/xml');
// Which section are we in?
// define('section', 'tv');
// Initialize the script, database, etc.
require_once "includes/init.php";
require_once "includes/programs.php";
require_once "includes/sorting.php";
// Parse the program list
$warning = NULL;
$recordings = get_backend_rows('QUERY_RECORDINGS Delete');
while (true) {
$Total_Used = 0;
$Total_Programs = 0;
$Programs = array();
$Groups = array();
$Program_Titles = array();
foreach ($recordings as $key => $record) {
// Skip the offset
if ($key === 'offset') // WHY IN THE WORLD DOES 0 == 'offset'?!?!? so we use ===
continue;
// Get the length (27 == recendts; 26 == recstartts)
$length = $record[27] - $record[26];
// keep track of their names and how many episodes we have recorded
$Total_Programs++;
$Groups[$record[30]]++;
// Hide LiveTV recordings from the title list
if (($_GET['recgroup'] && $_GET['recgroup'] == $record[30]) || (!$_GET['recgroup'] && $record[30] != 'LiveTV'))
$Program_Titles[$record[0]]++;
// Skip files with no chanid, or with zero length
if (!$record[4] || $length < 1)
continue;
// Hide livetv recordings from the default view
if (empty($_GET['recgroup']) && $record[30] == 'LiveTV')
continue;
// Make sure that everything we're dealing with is an array
if (!is_array($Programs[$record[0]]))
$Programs[$record[0]] = array();
// Assign a reference to this show to the various arrays
$Programs[$record[0]][] = $record;
}
// Did the best we could to find some programs; let's move on.
break;
}
// Now that we've selected only certain shows, load them into objects
$All_Shows = array();
foreach ($Programs as $title => $shows) {
foreach ($shows as $key => $record) {
// Create a new program object
$show =& new Program($record);
// Assign a reference to this show to the various arrays
$All_Shows[] =& $show;
$Programs[$title][$key] =& $show;
$Channels[$show->chanid]->programs[] =& $show;
unset($show);
}
}
// Sort the program titles
ksort($Program_Titles);
// The default sorting choice isn't so good for recorded programs, so we'll set our own default
if (!is_array($_SESSION['recorded_sortby']) || !count($_SESSION['recorded_sortby']))
$_SESSION['recorded_sortby'] = array(array('field' => 'airdate',
'reverse' => true),
array('field' => 'title',
'reverse' => false));
// Sort the programs
if (count($All_Shows)) {
sort_programs($All_Shows, 'recorded_sortby');
$builddate = date("r", time());
$xml = "\n";
$xml .= "\n";
$xml .= "\n";
$xml .= "Latest Recordings\n";
$xml .= "http://your.mythtv.host/mythweb/\n";
$xml .= "List of the Last 11 MythTV Recordings\n";
$xml .= "en-us\n";
$xml .= "{$builddate}\n";
if (sizeof($All_Shows) > 0) {
$i = 1;
foreach ($All_Shows as $show) {
if ($show->subtitle) $title = $show->title . ' (' . $show->subtitle . ')'; else $title = $show->title;
$xml .= "\n";
$xml .= "".htmlspecialchars($title,ENT_QUOTES)."\n";
$xml .= "".htmlspecialchars($show->description,ENT_QUOTES)."\n";
$xml .= "".htmlspecialchars(date('c', $show->starttime),ENT_QUOTES)."\n";
$xml .= "\n";
if ($i++ > 10) break;
}
}
$xml .= "\n";
$xml .= "\n";
} else {
$xml = "\n";
$xml .= "";
$xml .= "No recordings could be found";
$xml .= "";
}
print $xml;
?>