]> git.draconx.ca Git - mpdhacks.git/commitdiff
mpdexec: Add support for readpicture command in download mode.
authorNick Bowler <nbowler@draconx.ca>
Sun, 25 Jul 2021 16:58:18 +0000 (12:58 -0400)
committerNick Bowler <nbowler@draconx.ca>
Sun, 25 Jul 2021 17:03:24 +0000 (13:03 -0400)
mpdexec.pl

index 4d25ead18d81c979860f4044aa7e1da4f429a01a..72f81fe3b6336cbfcfa4f88d4299f7369eeb683a 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env perl
 #
-# Copyright © 2012,2019-2020 Nick Bowler
+# Copyright © 2012,2019-2021 Nick Bowler
 #
 # Send commands to MPD.  Each command-line argument is quoted as necessary
 # so it appears as a single argument at the protocol level.  The result is
@@ -32,7 +32,7 @@ my ($quiet, $binary, $ignore_errors, $download);
 sub print_version {
        print <<EOF
 mpdexec.pl 0.8
-Copyright © 2019 Nick Bowler
+Copyright © 2021 Nick Bowler
 License GPLv3+: GNU General Public License version 3 or any later version.
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.
@@ -61,10 +61,10 @@ Options:
                     written.  If FILE is specified, the data is written there.
                     Otherwise, --quiet is automatically enabled and the data
                     goes to standard output.
-  --download        Enable automatic sequencing of albumart commands; if this
-                    option is specified, albumart commands without offsets will
-                    be expanded into multiple commands in order to download the
-                    entire file.
+  --download        Enable automatic sequencing of albumart and readpicture
+                    commands; if this option is specified, such commands
+                    without offsets will be expanded into multiple commands
+                    in order to download the entire file.
   --ignore-errors   In batch mode, continue submitting commands after errors.
   -V, --version     Print a version message and then exit.
   -H, --help        Print this message and then exit.
@@ -118,13 +118,14 @@ sub read_binary {
        return $rc;
 }
 
+my %downloadcmds = map { $_ => 1 } ( "albumart", "readpicture" );
 sub mpd_exec {
        my $downloadseq;
 
-       # special case for "albumart"; if no offset is specified
-       # (invalid command) we synthesize a sequence of albumart
+       # special case for "albumart" and "readpicture"; if no offset is
+       # specified (invalid command) we synthesize a sequence of albumart
        # commands to retrieve the entire file.
-       if ($download && $_[0] eq "albumart" && @_ == 2) {
+       if ($download && $downloadcmds{$_[0]} && @_ == 2) {
                $_[2] = 0;
                $downloadseq = 2;
        }