CC-2016: Rearrange python scripts for reusability

-moved files
This commit is contained in:
martin 2011-03-24 00:00:46 -04:00
parent f9c8a7cc11
commit 5c8719d90c
70 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,73 @@
#!/usr/bin/perl -w
use strict ;
my $file = $ARGV[0] || die ;
sub test_mime {
my $file = shift ;
if (`which file`) {
return `file -b --mime-type "$file"`;
}
}
if (($file =~ /\.mp3$/i) || (test_mime($file) =~ /audio\/mpeg/)) {
if (`which mp3gain`) {
my $out = `mp3gain -q "$file" 2> /dev/null` ;
$out =~ /Recommended "Track" dB change: (.*)$/m || die ;
print "$1 dB\n" ;
} else {
print STDERR "Cannot find mp3gain binary!\n";
}
} elsif (($file =~ /\.ogg$/i) || (test_mime($file) =~ /application\/ogg/)) {
if ((`which vorbisgain`) && (`which ogginfo`)) {
system("vorbisgain -q -f \"$file\" 2>/dev/null >/dev/null") ;
my $info = `ogginfo "$file"` ;
$info =~ /REPLAYGAIN_TRACK_GAIN=(.*) dB/ || die ;
print "$1 dB\n" ;
} else {
print STDERR "Cannot find vorbisgain or ogginfo!\n";
}
} elsif (($file =~ /\.flac$/i) || (test_mime($file) =~ /audio\/x-flac/)) {
if (`which metaflac`) {
my $info = `metaflac --show-tag=REPLAYGAIN_TRACK_GAIN "$file"` ;
$info =~ /REPLAYGAIN_TRACK_GAIN=(.*) dB/;
if (defined($1)) {
print "$1 dB\n" ;
} else {
system("metaflac --add-replay-gain \"$file\" \
2>/dev/null >/dev/null") ;
$info = `metaflac --show-tag=REPLAYGAIN_TRACK_GAIN "$file"` ;
$info =~ /REPLAYGAIN_TRACK_GAIN=(.*) dB/ || die "Error in $file" ;
print "$1 dB\n" ;
}
} else {
print STDERR "Cannot find metaflac!\n";
}
} else {
print STDERR "File format not supported...\n";
}