Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env perl
- use strict;
- my $b = ($ARGV[0] eq 'b') ? 1 : 0;
- for my $file (<*.mkv>) {
- my ($trn, @tracks);
- print "$file\n";
- my @out = `mkvinfo --ui-language en "$file"`;
- foreach (@out) {
- $trn++ if /^\| \+ A track/;
- $tracks[$trn].=$_ if /^\| \+/;
- }
- my @keep;
- foreach (@tracks) {
- next unless /type: audio/;
- next if /Language: rus/;
- my ($track) = /Track number: (\d+)/;
- push @keep, --$track;
- }
- my $keep_tracks = join ',', @keep;
- die unless $keep_tracks;
- my $newfile = "_$file";
- `mkvmerge -o "$newfile" -a $keep_tracks "$file"`;
- unless ($b) {
- unlink $file;
- rename $newfile, $file;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement