2009-10-20, 11:45
Just to let you know the outcome. I have got this fixed - sort of.
I think that this was something to do with 'bom' perhaps and
unwanted characters being saved when I saved the
copy/paste for the first time.
The final code that I have on my XBMC is as follows, modified for my needs.
Note that this still only works remotely from another PC.
rss.asp
[HTML]<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://localhost:8080/" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Recently Added TV Shows</title>
<link>http://localhost:8080/rss.asp</link>
<description>Newly added shows</description>
<language>en</language>
<%
var setHeader;
var Response;
var resetHeader;
setHeader = xbmcAPI("setresponseformat(webheader;false;webfooter;false;opentag;<tag>;closetag;</tag>;openRecord;<item>;closeRecord;</item>;openField;\n;closeField;\n;closefinaltag;false)");
Response = xbmcAPI("QueryVideoDatabase(SELECT '\n<title>',strTitle,' - \"', C00,'\"</title>\n<description>New episode</description>\n' FROM episodeview ORDER BY idEpisode DESC Limit 6)");
write(Response);
resetHeader = xbmcAPI("SetResponseFormat()");
%>
</channel>
</rss>[/HTML]
To get this to work, I then open the file with php on my PC's server with curl
and strip out most things and format to compliant RSS again.
Thought I would post it for prosperity,
hope it helps someone in the future:
rss.php
Convoluted I know
I think that this was something to do with 'bom' perhaps and
unwanted characters being saved when I saved the
copy/paste for the first time.
The final code that I have on my XBMC is as follows, modified for my needs.
Note that this still only works remotely from another PC.
rss.asp
[HTML]<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://localhost:8080/" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Recently Added TV Shows</title>
<link>http://localhost:8080/rss.asp</link>
<description>Newly added shows</description>
<language>en</language>
<%
var setHeader;
var Response;
var resetHeader;
setHeader = xbmcAPI("setresponseformat(webheader;false;webfooter;false;opentag;<tag>;closetag;</tag>;openRecord;<item>;closeRecord;</item>;openField;\n;closeField;\n;closefinaltag;false)");
Response = xbmcAPI("QueryVideoDatabase(SELECT '\n<title>',strTitle,' - \"', C00,'\"</title>\n<description>New episode</description>\n' FROM episodeview ORDER BY idEpisode DESC Limit 6)");
write(Response);
resetHeader = xbmcAPI("SetResponseFormat()");
%>
</channel>
</rss>[/HTML]
To get this to work, I then open the file with php on my PC's server with curl
and strip out most things and format to compliant RSS again.
Thought I would post it for prosperity,
hope it helps someone in the future:
rss.php
PHP Code:
<?php
$file = 'http://<ATV:IP>/rss.asp';
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, $file);
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);
$s = '<rss version="2.0"';
$e = '</rss>';
$table_start = strpos($output, $s);
$table_end = strpos($output, $e) + strlen($e);
$table_len = $table_end - $table_start;
$what = array('</channel>','</rss>',"\n");
// purely source formating
$what2 = array(
'</title><description>',
'</description><title>',
'</item><item>',
'<item><title>',
'</description></item>'
);
$with = '';
$with2 = array(
"</title>\n<description>",
"</description>\n<title>",
"</item>\n<item>",
"<item>\n<title>",
"</description>\n</item>"
);
$pattern = array (
"/<rss [^>]*>(.*?)<\/language>/ims", '/\s\s+/',
"/<title [^>]*>(.*?)<\/title>/ims", '/\s\s+/',
"/<description [^>]*>(.*?)<\/description>/ims", '/\s\s+/'
);
$change = array (
'',
htmlentities("\\1"),
htmlentities("\\1")
);
$table = substr($output, $table_start, $table_len);
$table = preg_replace($pattern, $change, $table);
$table = str_replace ($what, $with, $table);
$table = str_replace ($what2, $with2, $table);
/*
*/
$channel_title = 'Newly added TV Shows';
$channel_link = 'http://<PC:IP>/';
$channel_desc = 'TV Show recently added on ATV';
header('Content-Type: application/rss+xml; charset=utf-8');
echo '<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="'. $channel_link .'" xmlns:dc="http://purl.org/dc/elements/1.1/">'."\n";
echo '<channel>
<title>'. $channel_title .'</title>
<link>'. $channel_link .'</link>
<description>'. $channel_desc .'</description>
<language>en</language>'."\n";
echo $table;
echo '
</channel>
</rss>';