Parcourir la source

Allow command-line specification of BASE_DIR

Zachary Kotlarek il y a 13 ans
Parent
commit
77f3af3825
1 fichiers modifiés avec 22 ajouts et 10 suppressions
  1. 22 10
      torrentMonitored.pl

+ 22 - 10
torrentMonitored.pl

@@ -11,21 +11,33 @@ my @skipped   = ();
 my @monitored = ();
 my @done      = ();
 
-# Media path(s)
+# Command-line parameters
+my ($prg, $base_dir) = @ARGV;
+
+# TV path(s)
 {
-	my $path = `~/bin/video/mediaPath` . '/TV';
-	if (-d $path) {
-		push(@BASE_DIRS, $path);
+	my $base = undef();
+	if (defined($base_dir) && -d $base_dir) {
+		$base = $base_dir;
+	} else {
+		my $cmd = $ENV{'HOME'} . '/bin/video/mediaPath';
+		if (-x $cmd) {
+			$base = `${cmd}`;
+		}
+	}
+
+	if (!defined($base)) {
+		die("No base directory available\n");
 	}
-	$path .= '/Downloads';
-	if (-d $path) {
-		push(@BASE_DIRS, $path);
+
+	foreach my $dir ('TV', 'Downloads') {
+		my $path = $base . '/' . $dir;
+		if (-d $path) {
+			push(@BASE_DIRS, $path);
+		}
 	}
 }
 
-# Command-line parameters
-my ($prg) = @ARGV;
-
 # For each directory
 for my $BASE_DIR (@BASE_DIRS) {