Native XBMC RSS feed for new shows and movies
#46
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

PHP Code:
<?php

$file 
'http://<ATV:IP>/rss.asp';

        
// create curl resource 
        
$ch curl_init(); 

        
// set url 
        
curl_setopt($chCURLOPT_URL$file); 

        
//return the transfer as a string 
        
curl_setopt($chCURLOPT_RETURNTRANSFER1); 

        
// $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>'

Convoluted I know Smile
Reply
#47
jabba_29 Wrote:rss.php

If you want to use php to create the feed there are much easier ways to do it.
1) Have php access the .db file directly
2) curl the httpapi directly from php (the main way create my feed).

I have sample code for the second option somewhere, I'll see if I can dig it up and share it...
Reply
#48
MPauley73 Wrote:If you want to use php to create the feed there are much easier ways to do it.
1) Have php access the .db file directly
2) curl the httpapi directly from php (the main way create my feed).

I have sample code for the second option somewhere, I'll see if I can dig it up and share it...
That would be great ... although this method will do for the time being...
Reply
#49
I installed this today and had some problems basically only "kizer's" scripts worked which were minus movie year adding year the same as other scripts resulted in nothing again not sure if this is a problem with later builds or just windows who knows

Anyway had a look in my db with SQLite browser just to better understand things and now have a working script with what I want eg : movie (Year) and TVShowTitle (Season X - Episode X), just thought I'd add to the mix

Assumes port 80 is being used

RssFeeds.xml

Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<rssfeeds>
  <!-- RSS feeds. To have multiple feeds, just add a feed to the set. You can also have multiple sets.     !-->
  <!-- To use different sets in your skin, each must be called from skin with a unique id.                 !-->
  <set id="1">
    <feed updateinterval="30">http://localhost:80/movies.asp</feed>
    <feed updateinterval="30">http://localhost:80/tv.asp</feed>
  </set>
</rssfeeds>

movies.asp

Code:
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Latest Added Movies</title>
<link>http://localhost:80/movies.asp/</link>
<description>This is my rss 2 feed for newest xbmc movies</description>
<language>en-us</language>

<%
var Response;
var setHeader;
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 '<title>', C00, ' (', C07,')', '</title>' from movie ORDER BY idMovie DESC LIMIT 5)");
write(Response);
resetHeader = xbmcAPI("SetResponseFormat()");
%>
</channel>
</rss>

tv.asp

Code:
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Latest Added TV</title>
<link>http://localhost:80/tv.asp/</link>
<description>This is my rss 2 feed for newest xbmc tv shows</description>
<language>en-us</language>

<%
var Response;
var setHeader;
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 '<title>',strTitle,': ', C00, ' (Season ', c12 , ' - Episode ', c13 ,')', '</title>', '<description>',c01,'</description>' FROM episodeview ORDER BY idEpisode DESC Limit 5)");
write(Response);
resetHeader = xbmcAPI("SetResponseFormat()");

%>
</channel>
</rss>
Reply

Logout Mark Read Team Forum Stats Members Help
Native XBMC RSS feed for new shows and movies0