Zachary Kotlarek 8 vuotta sitten
vanhempi
sitoutus
411784ac50
2 muutettua tiedostoa jossa 20 lisäystä ja 6 poistoa
  1. 10 3
      rss.pl
  2. 10 3
      yt/subscribe.pl

+ 10 - 3
rss.pl

@@ -114,10 +114,12 @@ for my $entry ($feed->entries()) {
 					$ext = 'mp3';
 				} elsif ($enc->{'type'} =~ /video\//i) {
 					if ($DEBUG > 1) {
-						print STDERR 'Skipping video file: ' . time2str('%Y-%m-%d', $time) . "\n";
+						warn('Skipping video file: ' . time2str('%Y-%m-%d', $time) . "\n");
 					}
 				} else {
-					print STDERR 'Unknown MIME type: ' . $enc->{'type'} . "\n";
+					if ($DEBUG) {
+						warn('Unknown MIME type: ' . $enc->{'type'} . "\n");
+					}
 				}
 			}
 			if (exists($enc->{'length'})) {
@@ -216,7 +218,12 @@ while (my $file = readdir($fh)) {
 		if (exists($episodes{$time})) {
 			if (exists($episodes{$time}->{'size'}) && $episodes{$time}->{'size'}) {
 				(undef(), undef(), undef(), undef(), undef(), undef(), undef(), my $size) = stat($path);
-				my $ratio = ($size / $episodes{$time}->{'size'});
+				my $ratio = 1;
+				if ($episodes{$time}->{'size'} =~ /^\d$/) {
+					$ratio = ($size / $episodes{$time}->{'size'});
+				} elsif ($DEBUG) {
+					warn('Invalid episode size: ' . $episodes{$time}->{'size'});
+				}
 				if ($ratio < (1 - $ERR_RATIO) && $DEBUG) {
 					print STDERR 'Invalid output file size (' . $size . '/' . $episodes{$time}->{'size'} . '): ' . $file . "\n";
 				}

+ 10 - 3
yt/subscribe.pl

@@ -323,7 +323,9 @@ foreach my $id (keys(%{$files})) {
 		}
 
 		# Whine when videos do go away
-		warn('Local video not known to YT channel (' . $NAME . '): ' . $id . "\n");
+		if ($DEBUG) {
+			warn('Local video not known to YT channel (' . $NAME . '): ' . $id . "\n");
+		}
 		renameVideo($files->{$id}->{'path'}, $files->{$id}->{'suffix'}, $files->{$id}->{'nfo'}, $id, 0, $files->{$id}->{'season'} . $files->{$id}->{'number'});
 	}
 }
@@ -1095,7 +1097,10 @@ sub getVideoData($) {
 		&& ref($data->{'items'}) eq 'ARRAY')
 	{
 		if (scalar(@{$ids}) > 1 && $data->{'pageInfo'}->{'totalResults'} != scalar(@{$ids})) {
-			die($NAME . ': Video/metadata search count mismatch: ' . $data->{'pageInfo'}->{'totalResults'} . '/' . scalar(@{$ids}) . "\n");
+			if ($DEBUG) {
+				die($NAME . ': Video/metadata search count mismatch: ' . $data->{'pageInfo'}->{'totalResults'} . '/' . scalar(@{$ids}) . "\n");
+			}
+			exit(0);
 		}
 		$data = $data->{'items'};
 	} else {
@@ -1343,7 +1348,9 @@ sub renameVideo($$$$$$) {
 			die($NAME . ': Invalid video source in rename: ' . $video . "\n");
 		}
 		if ($video ne $videoNew) {
-			print STDERR 'Renaming ' . $NAME . '/' . $video . ' => ' . $videoNew . "\n";
+			if ($DEBUG) {
+				warn('Renaming ' . $NAME . '/' . $video . ' => ' . $videoNew . "\n");
+			}
 			if (-e $videoNew) {
 				die($NAME . ': Rename: Target exists: ' . $videoNew . "\n");
 			}