]> git.draconx.ca Git - mpdhacks.git/commitdiff
mpdmenu: Use embedded cover art.
authorNick Bowler <nbowler@draconx.ca>
Thu, 29 Jul 2021 00:47:34 +0000 (20:47 -0400)
committerNick Bowler <nbowler@draconx.ca>
Thu, 29 Jul 2021 00:47:34 +0000 (20:47 -0400)
If the server supports embedded cover art, all we need to do now is
pass --embedded to the thumbnailer and everything will Just Work™

mpdmenu.pl

index 15a49b27d4cda4bf4598e9e218ce7557edf3cc50..e53647065a0a3a5d50596b83fd37112ef9f7f3d4 100755 (executable)
@@ -35,7 +35,7 @@ use constant {
 my $SELF = "$FindBin::Bin/$FindBin::Script";
 
 my $MUSIC = $ENV{MUSIC}    // "/srv/music";
-my $sock;
+my ($sock, $mpd_have_binarylimit);
 
 my ($albumid, $albumname, $trackid, $recordingid);
 my ($topmenu, $menu);
@@ -134,6 +134,13 @@ sub get_item_thumbnails {
                $c = "%";
        }
 
+       if ($mpd_have_binarylimit) {
+               # --embedded implies and requires binarylimit support
+               push @opts, "--embedded";
+       } else {
+               push @opts, "--no-binarylimit";
+       }
+
        open THUMB, "-|", "$FindBin::Bin/mpdthumb.sh", @opts, "--", @_;
        foreach (@_) {
                my $thumb = <THUMB>;
@@ -613,6 +620,12 @@ $sock = MPD::connect();
 die("MPD version $MPD::major.$MPD::minor.$MPD::revision insufficient.")
        unless MPD::min_version(MPD_MJR_MIN, MPD_MNR_MIN, MPD_REV_MIN);
 
+MPD::exec("binarylimit", 64);
+while (<$sock>) {
+       $mpd_have_binarylimit = 1 if /^OK/;
+       last if /^OK/ or /^ACK/;
+}
+
 if ($mode eq "top") {
        my %current;
        my %state;