All pastes #281825 Raw Edit

Unnamed

public text v1 · immutable
#281825 ·published 2006-12-17 02:32 UTC
rendered paste body
use strict;
use warnings "all";
use LWP::UserAgent;

my $dir = "."; #where you want to save the torrents, default is same directory this file is in
my $ua = LWP::UserAgent->new;
$ua->agent("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7");
$ua->timeout("10");

&rss_check;

sub rss_check {
	my $res = $ua->get("http://tokyotosho.com/rss.php");
	if($res->is_success){
		my $content = $res->content;
		while($content=~s/<item><category>Anime<\/category><title>(.+?)<\/title><link><!\[CDATA\[(.+?)\]\]><\/link>//){
			my $title = $1; my $link = $2;
			&dl($link);
		}
	}
}

sub dl {
	my $link = shift;
	my $tname = $link;
	$tname=~s/.+\/(.+?=)?//;
	use URI::Escape;
	$tname = uri_unescape($tname);
	if(!-e "$dir/$tname"){
		my $res = $ua->get($link, ":content_file" => "$dir/$tname");
		if($res->is_success){ print "Downloaded torrent: $tname\n"; }
		else { print "Failed to get link: $link\n"; }
	}
}