From 9c9061da3b1c202d47dca2008bb4a5cfb9814c7b Mon Sep 17 00:00:00 2001 From: moex3 <46636583+moex3@users.noreply.github.com> Date: Sun, 14 Mar 2021 14:32:42 +0100 Subject: [PATCH] Add a flag to specify a cover image to add --- flac-mass-transcode.pl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/flac-mass-transcode.pl b/flac-mass-transcode.pl index 3d1e0fe..fc4e094 100755 --- a/flac-mass-transcode.pl +++ b/flac-mass-transcode.pl @@ -9,9 +9,11 @@ use File::Copy qw(copy); my $updir = 0; my $help = 0; +my $forcecover; GetOptions( "help" => \$help, - "updir=i" => \$updir) + "updir=i" => \$updir, + "cover=s" => \$forcecover) or die("Error in command line options"); if ($help) { @@ -37,8 +39,8 @@ for (my $i = 0; $i < @flacMapPaths; $i += 2) { $inp = qq($inp); $out = qq($out); my $coverOpts = ""; - my $cover = undef; - if (!hasImage($inp) && defined($cover = getcover($inp))) { + my $cover = $forcecover; + if ($cover || (!hasImage($inp) && defined($cover = getcover($inp)))) { $coverOpts .= qq(--picture "$cover"); print("## Adding cover $cover ##\n"); } @@ -116,7 +118,7 @@ sub mapInputToOutput { ## Easy, just print how to use sub usage { - print("Usage: $0 [-h | --help] [-u | --uplevel NUM] \n"); + print("Usage: $0 [-h | --help] [-u | --uplevel NUM] [-c | --cover IMG] \n"); exit 1; } @@ -125,8 +127,9 @@ sub help { Usage: flac-mass-transcode.pl [options] - -h, --help print this help text - -u, --uplevel take this number of directories from the input path + -h, --help print this help text + -u, --uplevel NUM take this number of directories from the input path + -c, --cover IMG add this image as an album cover EOF print("$h"); exit 0;