-reorganized/cleaned up python_apps/pypo directory.
This commit is contained in:
parent
f66305e3d3
commit
9cfec2c8ef
42 changed files with 14 additions and 338 deletions
73
python_apps/pypo/liquidsoap_scripts/library/extract-replaygain
Executable file
73
python_apps/pypo/liquidsoap_scripts/library/extract-replaygain
Executable 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";
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue