Jump to content

mininova rss fix


mdpauley

Recommended Posts

All you need is a web server with php. This script pulls the feed from mininova, replaces some text and then creates a local copy to keep the load off of mininova. Hope this helps someone else...

<?php

header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, no-store, must-revalidate");

function getMiniNova(){
$filename = 'mininova.rss';
$lastmodify = date ("YmdHis", filemtime($filename));
$now = date ("YmdHis", mktime(date("h"), date("i") - 15, date("s"), date("m"), date("d"), date("Y")));
if ($now > $lastmodify){
$s_url = 'http://www.mininova.org/rss.xml';
$o_ch = curl_init();
curl_setopt ($o_ch, CURLOPT_URL, $s_url);
curl_setopt ($o_ch, CURLOPT_HEADER, 0);
curl_setopt ($o_ch, CURLOPT_RETURNTRANSFER, 1);
$s_html = curl_exec ($o_ch);
curl_close ($o_ch);
unset($o_ch);
$s_html = str_replace("http://www.mininova.org/tor/", "http://www.mininova.org/get/", $s_html);

$handle = fopen($filename, 'w');
fwrite($handle, $s_html);
fclose($handle);
$s_html = $s_html;
} else {
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
$s_html = $contents;

}
return $s_html;
}

$data = getMiniNova();
echo $data;
?>

Link to comment
Share on other sites

Hm, if you've already got a webserver running, why not just output the result to the client instead of writing it to file? In that way, you can just tell µTorrent to connect to http://localhost:port/path/mininova.php (or whatever you name the file). Saves a bit of unnecessary/extra disk read/writes (very minor, but still, more elegant).

The functionality behind this is not unlike the functionality behind RSSatellite (on-the-fly text replacement for RSS feeds), only RSSatellite behaves as I've described (output to client instead of disk).

Link to comment
Share on other sites

My original thought was to post this on a server that I have and allow people to pull from it, but then I started to think of possible legal problems so I thought I would post it for everyone to use on their own. Writing to a file would create a cache so I wouldn't have to pull from mininova everytime someone requested the feed. I've been using utorrent from the start, but I just started reading the forums, I was not aware of RSSatellite (plus I am a code geek ;-))

Link to comment
Share on other sites

The only reason I'd suggest this is that µTorrent currently doesn't support local RSS feeds unless they're hosted on a local webserver. µTorrent 1.8, IINM, should "fix" this lack, but until then, the stored file is unusable in µTorrent anyway. Really, though, I never thought about the caching aspect, and when looked at in that way, I guess your solution makes sense :P

Edit: Er, just realized that you're writing to a hosted location anyway :| Nevermind xD

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...