Zachary Kotlarek 11 лет назад
Родитель
Сommit
e9bceb141c
1 измененных файлов с 10 добавлено и 9 удалено
  1. 10 9
      yt/subscribe.pl

+ 10 - 9
yt/subscribe.pl

@@ -277,7 +277,7 @@ foreach my $id (keys(%{$videos})) {
 			$rename = -1;
 			$rename = -1;
 		}
 		}
 	}
 	}
-	if ($files->{$id}->{'number'} != $videos->{$id}->{'number'}
+	if (   $files->{$id}->{'number'} != $videos->{$id}->{'number'}
 		|| $files->{$id}->{'season'} != $videos->{$id}->{'season'})
 		|| $files->{$id}->{'season'} != $videos->{$id}->{'season'})
 	{
 	{
 		$rename = 1;
 		$rename = 1;
@@ -530,6 +530,7 @@ sub findFiles() {
 	while (my $file = readdir($fh)) {
 	while (my $file = readdir($fh)) {
 		my ($season, $num, $id, $suffix) = parseFilename($file);
 		my ($season, $num, $id, $suffix) = parseFilename($file);
 		if (defined($id) && length($id) > 0) {
 		if (defined($id) && length($id) > 0) {
+
 			# Create the record as needed
 			# Create the record as needed
 			if (!exists($files{$id})) {
 			if (!exists($files{$id})) {
 				my %tmp = (
 				my %tmp = (
@@ -550,7 +551,7 @@ sub findFiles() {
 				if ($type eq 'nfo') {
 				if ($type eq 'nfo') {
 					warn('Duplicate NFO: ' . $id . "\n\t" . $files{$id}->{'nfo'} . "\n\t" . $file . "\n");
 					warn('Duplicate NFO: ' . $id . "\n\t" . $files{$id}->{'nfo'} . "\n\t" . $file . "\n");
 					if (!$NO_RENAME) {
 					if (!$NO_RENAME) {
-						warn("\tDeleting: " .  $file . "\n");
+						warn("\tDeleting: " . $file . "\n");
 						if ($SUDO_CHATTR) {
 						if ($SUDO_CHATTR) {
 							system('sudo', 'chattr', '-i', $file);
 							system('sudo', 'chattr', '-i', $file);
 						}
 						}
@@ -564,7 +565,7 @@ sub findFiles() {
 						if ($suffix ne 'mp4' && $files{$id}->{'suffix'} eq 'mp4') {
 						if ($suffix ne 'mp4' && $files{$id}->{'suffix'} eq 'mp4') {
 							$del = $files{$id}->{'path'};
 							$del = $files{$id}->{'path'};
 						}
 						}
-						warn("\tDeleting: " .  $del . "\n");
+						warn("\tDeleting: " . $del . "\n");
 						if ($SUDO_CHATTR) {
 						if ($SUDO_CHATTR) {
 							system('sudo', 'chattr', '-i', $del);
 							system('sudo', 'chattr', '-i', $del);
 						}
 						}
@@ -1017,7 +1018,7 @@ sub renameVideo($$$$$$) {
 
 
 		# Sanity checks, as we do dangerous work here
 		# Sanity checks, as we do dangerous work here
 		if (!-r $video) {
 		if (!-r $video) {
-			die('Invalid video sources in rename: ' . $video . "\n");
+			die('Invalid video source in rename: ' . $video . "\n");
 		}
 		}
 		if ($video ne $videoNew) {
 		if ($video ne $videoNew) {
 			print STDERR 'Renaming ' . $video . ' => ' . $videoNew . "\n";
 			print STDERR 'Renaming ' . $video . ' => ' . $videoNew . "\n";
@@ -1036,15 +1037,15 @@ sub renameVideo($$$$$$) {
 	if (defined($nfo)) {
 	if (defined($nfo)) {
 		my $nfoNew = videoPath($season, $episode, $id, 'nfo');
 		my $nfoNew = videoPath($season, $episode, $id, 'nfo');
 
 
+		# Sanity checks, as we do dangerous work here
+		if (!-r $nfo) {
+			die('Invalid NFO source in rename: ' . $nfo . "\n");
+		}
+
 		# Parse old NFO data
 		# Parse old NFO data
 		my $nfoData = updateNFOData($nfo, $season, $episode)
 		my $nfoData = updateNFOData($nfo, $season, $episode)
 		  or die('No NFO data found, refusing to rename: ' . $id . "\n");
 		  or die('No NFO data found, refusing to rename: ' . $id . "\n");
 
 
-		# Sanity checks, as we do dangerous work here
-		if (!-r $video) {
-			die('Invalid video sources in rename: ' . $video . "\n");
-		}
-
 		# Write a new NFO and unlink the old one
 		# Write a new NFO and unlink the old one
 		if ($SUDO_CHATTR) {
 		if ($SUDO_CHATTR) {
 			system('sudo', 'chattr', '-i', $nfo);
 			system('sudo', 'chattr', '-i', $nfo);