Add a flag to specify a cover image to add

This commit is contained in:
moex3 2021-03-14 14:32:42 +01:00
parent 77a42fe95a
commit 9c9061da3b
No known key found for this signature in database
GPG Key ID: ABC92E00CF59BB7A

View File

@ -9,9 +9,11 @@ use File::Copy qw(copy);
my $updir = 0; my $updir = 0;
my $help = 0; my $help = 0;
my $forcecover;
GetOptions( GetOptions(
"help" => \$help, "help" => \$help,
"updir=i" => \$updir) "updir=i" => \$updir,
"cover=s" => \$forcecover)
or die("Error in command line options"); or die("Error in command line options");
if ($help) { if ($help) {
@ -37,8 +39,8 @@ for (my $i = 0; $i < @flacMapPaths; $i += 2) {
$inp = qq($inp); $inp = qq($inp);
$out = qq($out); $out = qq($out);
my $coverOpts = ""; my $coverOpts = "";
my $cover = undef; my $cover = $forcecover;
if (!hasImage($inp) && defined($cover = getcover($inp))) { if ($cover || (!hasImage($inp) && defined($cover = getcover($inp)))) {
$coverOpts .= qq(--picture "$cover"); $coverOpts .= qq(--picture "$cover");
print("## Adding cover $cover ##\n"); print("## Adding cover $cover ##\n");
} }
@ -116,7 +118,7 @@ sub mapInputToOutput {
## Easy, just print how to use ## Easy, just print how to use
sub usage { sub usage {
print("Usage: $0 [-h | --help] [-u | --uplevel NUM] <input_dir> <output_dir>\n"); print("Usage: $0 [-h | --help] [-u | --uplevel NUM] [-c | --cover IMG] <input_dir> <output_dir>\n");
exit 1; exit 1;
} }
@ -125,8 +127,9 @@ sub help {
Usage: Usage:
flac-mass-transcode.pl [options] <input_dir> <output_dir> flac-mass-transcode.pl [options] <input_dir> <output_dir>
-h, --help print this help text -h, --help print this help text
-u, --uplevel take this number of directories from the input path -u, --uplevel NUM take this number of directories from the input path
-c, --cover IMG add this image as an album cover
EOF EOF
print("$h"); print("$h");
exit 0; exit 0;