Skip to content

Commit

Permalink
Skip, record errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyA committed Mar 20, 2014
1 parent f41810a commit 235daf4
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion bin/sift
Expand Up @@ -18,6 +18,8 @@ my %O = (
],
);

my @failed = ();

GetOptions( 'o:s' => \$O{o} ) or die;

for my $obj (@ARGV) {
Expand All @@ -43,10 +45,32 @@ for my $obj (@ARGV) {
$obj;
}

if (@failed) {
print "Problems:\n";
for my $fail (@failed) {
print " $fail->{file}: $fail->{msg}\n";
}
}

sub tidy {
my $str = shift;
for ($str) { s/^\s+//; s/\s+$// }
return $str;
}

sub fail {
my ( $file, $msg ) = @_;
push @failed, { file => $file, msg => tidy($msg) };
}

sub sift {
my $file = file shift;
my $info = mediainfo($file);
print "$file\n";
my $info = eval { mediainfo($file) };
unless ($info) {
fail( $file, $@ );
return;
}
my $dir = $file->parent;
my $name = $file->basename;
for my $key ( @{ $O{key} } ) {
Expand Down

0 comments on commit 235daf4

Please sign in to comment.