소스 검색

Look for a default excludes file, but allow it to be disabled with an empty string or invalid path. Warn when debugging and no excludes file is processed.

Zachary Kotlarek 11 년 전
부모
커밋
aeca9dbaac
1개의 변경된 파일과 9개의 추가작업 그리고 3개의 파일을 삭제
  1. 9 3
      findTorrent.pl

+ 9 - 3
findTorrent.pl

@@ -33,7 +33,7 @@ my $TIMEOUT       = 15;
 my $ERR_DELAY     = $TIMEOUT * 2;
 my $ERR_RETRIES   = 3;
 my $UA            = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A';
-my $EXCLUDES_FILE = undef();
+my $EXCLUDES_FILE = $ENV{'HOME'} . '.findTorrent.exclude';
 
 # Static tracker list, appended to all magnet URIs
 my @TRACKERS = ('udp://open.demonii.com:1337/announce', 'udp://tracker.publicbt.com:80/announce', 'udp://tracker.openbittorrent.com:80/announce', 'udp://9.rarbg.com:2710/announce');
@@ -81,7 +81,7 @@ if ($ENV{'DEBUG'}) {
 		$DEBUG = 1;
 	}
 }
-if ($ENV{'EXCLUDES_FILE'}) {
+if (exists($ENV{'EXCLUDES_FILE'})) {
 	$EXCLUDES_FILE = $ENV{'EXCLUDES_FILE'};
 }
 if ($ENV{'NO_QUALITY_CHECKS'}) {
@@ -102,7 +102,7 @@ if (defined($ENV{'NEXT_EPISODES'})) {
 
 # Read the torrent excludes list
 my %EXCLUDES = ();
-if ($EXCLUDES_FILE) {
+if ($EXCLUDES_FILE && -r $EXCLUDES_FILE) {
 	my $fh;
 	open($fh, '<', $EXCLUDES_FILE)
 	  or die('Unable to open excludes file: ' . $EXCLUDES_FILE . ': ' . $! . "\n");
@@ -124,6 +124,12 @@ if ($EXCLUDES_FILE) {
 		}
 	}
 	close($fh);
+} elsif ($DEBUG) {
+	print STDERR 'No excludes file available';
+	if ($EXCLUDES_FILE) {
+		print STDERR ': ' . $EXCLUDES_FILE;
+	}
+	print STDERR "\n";
 }
 
 # Figure out what we're searching for