1
0
mirror of https://github.com/moex3/flac2mp3.pl synced 2024-11-22 12:04:16 -05:00

Compare commits

..

No commits in common. "7aebd5fc772e66617cf9f28587ca5c67c939acd9" and "dfb21dfc2bb2d519b6dd504bccea0310e2256b47" have entirely different histories.

View File

@ -93,10 +93,6 @@ if (scalar(@ARGV) != 2) {
my ($IDIR, $ODIR) = @ARGV;
if (!-e $ODIR) {
mkdir $ODIR;
}
find({ wanted => \&iterFlac, no_chdir => 1 }, $IDIR);
sub iterFlac {
@ -105,7 +101,6 @@ sub iterFlac {
my @required_tags = ("artist", "title", "album", "tracknumber");
my $flac = $_;
shellsan(\$flac);
my $dest = "$ODIR/" . basename($flac);
$dest =~ s/\.flac$/\.mp3/;
my $tags = getFlacTags($flac);
@ -125,7 +120,7 @@ sub iterFlac {
argsToTags($tags);
my $tagopts = tagsToOpts($tags);
qx(flac -cd -- '$flac' | lame -V0 -S --vbr-new --add-id3v2 @$tagopts - '$dest');
qx(flac -cd "$flac" | lame -V0 -S --vbr-new --add-id3v2 @$tagopts - "$dest");
}
sub argsToTags {
@ -148,17 +143,15 @@ sub tagsToOpts {
my $tagName = $idLookup{$currKey};
my $type = ref($tagName);
if ($type eq "" && defined($tagName)) {
my $tagCont = $tags->{$currKey};
shellsan(\$tagCont);
push(@tagopts, qq(--tv '$tagName=$tagCont'));
push(@tagopts, qq(--tv '$tagName=$tags->{$currKey}'));
} elsif ($type eq "ARRAY") {
my $tagCont = $tagName->[1]->($tags);
shellsan(\$tagCont);
push(@tagopts, qq(--tv '$tagName->[0]=$tagCont'));
}
}
#print(Dumper(\@tagopts));
return \@tagopts;
}
@ -166,7 +159,7 @@ sub getFlacTags {
my $flac = shift;
my %tags;
my @tagtxt = qx(metaflac --list --block-type=VORBIS_COMMENT -- '$flac');
my @tagtxt = qx(metaflac --list --block-type=VORBIS_COMMENT -- "$flac");
foreach my $tagline (@tagtxt) {
if ($tagline =~ /comment\[\d+\]:\s(.*?)=(.*)/) {
$tags{lc($1)} = $2;
@ -175,10 +168,6 @@ sub getFlacTags {
return \%tags;
}
sub shellsan {
${$_[0]} =~ s/'/'\\''/g;
}
sub usage {
print("Usage: flac2mp3.pl [-h | --help] [-g | --genre NUM] <input_dir> <output_dir>\n");
exit 1;