Recently I've discovered that utorrent has nice feature that allows you to download files directly from rss, and since every show on tvu has individual feed, why not use it ? This is my first script in perl so I'm not so sure about it, but it works so far. It's designed to work with mldonkey but if you are using amule you can just execute amulecmd instead of telnet, and windows users can execute emule.exe with ed2klink. Configuration is pretty easy, fill up connection info(mldonkey), which season you wish to keep eye on and which files you already have. Variables are now set to 7th season of '24' hdtv (350mb) version, without the last episode. Paste it to file, chmod +x and execute in screen or dtach
#!/usr/bin/perl -w
use strict;
use HTML::Element;
use HTML::TreeBuilder;
use XML::RSS;
use LWP::Simple;
use Net::Telnet;
use Time::Local;
sub if_not_in_tab {
my ($needle,@haystack) = @_;
my $count=@haystack;
my $i=0;
while($i<$count){
if($haystack[$i]==$needle){
return 0;
}
$i++;
}
return 1;
}
my $rss = new XML::RSS;
#mld host user and pass
my $host="";
my $user="";
my $pass="";
#season id
my $season = '24566';
#fill array with file_ids that you already have
my @ihave = (270587, 371711, 371715, 371827, 371832, 373105, 374096, 375322);
while(1){
my $data = get('http://tvunderground.org.ru/rss.php?se_id='.$season);
if($data){
if($rss -> parse($data)){
my @tab = ();
foreach my $item (@{$rss->{'items'}}){
next unless defined($item->{'guid'});
$_=$item->{'guid'};
if( /%5B(.*)%5D/ ) {
if(if_not_in_tab($1,@ihave)){
unshift(@tab,$1);
}
}
}
my $howmanyfound=@tab;
if($howmanyfound>0){
my $i=0;
print "Found ".$howmanyfound." new files ".localtime(time())."\n";
while($i<$howmanyfound){
my $url='http://tvunderground.org.ru/index.php?show=ed2k&season='.$season.'&sid['.$tab[$i].']=1';
my $tree = HTML::TreeBuilder->new();
$data=get($url);
if($data){
$tree->utf8_mode(1);
if($tree->parse($data)){
my $ed2k = $tree->find_by_attribute('name','ed2klink');
print "Found: ".$ed2k->attr('href')."\n";
my $telnet = new Net::Telnet (Timeout=>10,Errmode=>'die',Port=>4000);
if($telnet){
$telnet->open($host);
$telnet->waitfor('/> $/');
sleep(1);
$telnet->print('auth '.$user.' '.$pass);
sleep(1);
$telnet->print('dllink '.$ed2k->attr('href'));
$telnet->print('q');
unshift(@ihave,$tab[$i]);
}
$i++;
}
}
$tree=$tree->delete;
}
}
}
}
sleep(1800);#sleep for 30 min
}
This script shows what files are already available (paste output to ihave array)
#!/usr/bin/perl -w
use strict;
use XML::RSS;
use LWP::Simple;
my $rss = new XML::RSS;
#season id
my $season = '24566';
my $data=get('http://tvunderground.org.ru/rss.php?se_id='.$season);
$rss->parse($data);
my @tab = ();
foreach my $item (@{$rss->{'items'}}){
next unless defined($item->{'guid'});
$_=$item->{'guid'};
if( /%5B(.*)%5D/ ) {
unshift(@tab,$1);
}
}
my $i=0;
my $hm=@tab;
while($i<$hm){
print "$tab[$i]";
$i++;
if($i!=$hm){print ",";}
}
print "\n";





















