Advertisement
Guest User

Untitled

a guest
Oct 14th, 2014
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.64 KB | None | 0 0
  1. #!/usr/bin/env perl
  2.  
  3. use strict;
  4.  
  5. my $b = ($ARGV[0] eq 'b') ? 1 : 0;
  6.  
  7. for my $file (<*.mkv>) {
  8.     my ($trn, @tracks);
  9.  
  10.     print "$file\n";
  11.     my @out = `mkvinfo --ui-language en "$file"`;
  12.     foreach (@out) {
  13.         $trn++ if /^\| \+ A track/;
  14.         $tracks[$trn].=$_ if /^\|  \+/;
  15.     }
  16.  
  17.     my @keep;
  18.     foreach (@tracks) {
  19.         next unless /type: audio/;
  20.         next if /Language: rus/;
  21.         my ($track) = /Track number: (\d+)/;
  22.         push @keep, --$track;
  23.     }
  24.     my $keep_tracks = join ',', @keep;
  25.     die unless $keep_tracks;
  26.  
  27.     my $newfile = "_$file";
  28.     `mkvmerge -o "$newfile" -a $keep_tracks "$file"`;
  29.     unless ($b) {
  30.         unlink $file;
  31.         rename $newfile, $file;
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement