Explorar o código

Debug local metadata overrides

Zachary Kotlarek %!s(int64=11) %!d(string=hai) anos
pai
achega
6eaf3b30ee
Modificáronse 1 ficheiros con 8 adicións e 5 borrados
  1. 8 5
      yt/subscribe.pl

+ 8 - 5
yt/subscribe.pl

@@ -1039,7 +1039,7 @@ sub getVideoData($) {
 		# Allow local overrides to metadata
 		{
 			my $id   = $video->{'id'};
-			my $meta = $id . '.local';
+			my $meta = $id . '.meta';
 			if (!-r $meta) {
 				next;
 			}
@@ -1050,20 +1050,23 @@ sub getVideoData($) {
 				if (/^\s*#/ || /^\s*$/) {
 					next;
 				}
-				if (/^\s*(\S[^\=]+)\s*=\s*(\S.*\S)\s*$/) {
+				if (/^\s*([^\s\=][^\=]*[^\s\=])\s*=\>?\s*(\S.*\S)\s*$/) {
 					if (exists($video->{$1})) {
-						$video->{$1} = $2;
 						if ($DEBUG) {
 							print STDERR 'Using local metadata line (' . $id . '): ' . $1 . ' => ' . $2 . "\n";
 						}
+						$video->{$1} = $2;
+					} else {
+						die('Invalid local metadata attribute (' . $1 . '): ' . $meta . "\n");
 					}
-				} elsif ($DEBUG) {
-					print STDERR 'Skipping invalid local metdata line (' . $id . '): ' . chomp($_) . "\n";
+				} else {
+					die('Invalid local metdata line (' . $meta . '): ' . chomp($_) . "\n");
 				}
 			}
 			close($fh);
 		}
 
+		# Save
 		push(@videos, $video);
 	}