#!/usr/local/bin/perl my $emailnotify=0; my $email="root\@localhost"; my $logfile="/home/boss/.torrentlog"; my $wantfile="/home/boss/.torrentshows"; my %donehash; my %wanthash; my $torrentdir="/home/boss/eztv/"; open(WANT, $wantfile); while (my $want = ) { chomp $want; next unless (length($want)); $wanthash{$want}=1; } close WANT; open(LOG, $logfile); while (my $line = ) { chomp $line; next unless (length($line)); $donehash{$line}=1; } close LOG; open(LOG, ">>".$logfile); while (my $line = ) { chomp $line; next unless (index($line, '') > -1); my @f=split('', $line); foreach my $k (@f) { my $tshow = $k; $tshow =~ s!.*(.*).*!$1!; $tshow =~ s!\ \[eztv\]!!g; my $url = $k; $url =~ s!.*(.*).*!$1!; $url =~ s/tor/get/; $url =~ /(\d{6})/; my $file="$1.torrent"; next unless (index($url, 'http://') > -1); next unless (wanted($tshow)); next if ($donehash{$url}); next if ($tshow =~ /x264/i); print LOG "$url\n"; system("wget --quiet -U 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6' -O $torrentdir/$file $url"); if ($emailnotify) { system("echo $tshow downloading. | mail -s 'New Torrent: $tshow' $email"); } #print "URL: $url, File: $file, Show: $tshow\n"; } } sub wanted { my $s=shift; $s=lc($s); foreach my $k (keys %wanthash) { $k=lc($k); return 1 if ($s =~ /$k/); } return 0; } __END__