]> git.draconx.ca Git - mpdhacks.git/log
mpdhacks.git
2 years agompdthumb: Fix failure when readpicture/albumart both return data. master
Nick Bowler [Thu, 10 Feb 2022 01:00:49 +0000 (20:00 -0500)]
mpdthumb: Fix failure when readpicture/albumart both return data.

If a file has both embedded cover art and cover art in its directory,
both commands will return data and mpdthumb prints two lines instead
of one as expected.  Fix this by skipping the check for albumart data
if valid readpicture data was returned.

2 years agompdmenu: Add thumbnails to standalone recording menus.
Nick Bowler [Thu, 29 Jul 2021 04:04:13 +0000 (00:04 -0400)]
mpdmenu: Add thumbnails to standalone recording menus.

I think in typical usage cover images for standalone recordings will be
embedded and different for each file.  It's more like a list of 1-track
albums rather than a list of tracks from the same album, so probably
nice to add the images.

2 years agompdmenu: Use embedded cover art.
Nick Bowler [Thu, 29 Jul 2021 00:47:34 +0000 (20:47 -0400)]
mpdmenu: Use embedded cover art.

If the server supports embedded cover art, all we need to do now is
pass --embedded to the thumbnailer and everything will Just Work™

2 years agompdmenu: Add MusicBrainz links for the current track.
Nick Bowler [Thu, 29 Jul 2021 00:14:00 +0000 (20:14 -0400)]
mpdmenu: Add MusicBrainz links for the current track.

Having a feature to directly open relevant track and artist
pages on the web seems quite handy.

2 years agompdmenu: Improve support for standalone recordings.
Nick Bowler [Wed, 28 Jul 2021 02:38:45 +0000 (22:38 -0400)]
mpdmenu: Improve support for standalone recordings.

Standalone recordings have a slightly different metadata structure from
tracks associated with releases.  Let's handle them by presenting all the
standalone recordings for an artist together as if they were an actual
release by that artist.

2 years agompdthumb: Add support for embedded cover art.
Nick Bowler [Sun, 25 Jul 2021 17:08:11 +0000 (13:08 -0400)]
mpdthumb: Add support for embedded cover art.

MPD has recently gained the "readpicture" command in order to retrieve
cover images embedded in files.  This works very similarly to albumart.

We now have the necessary features in mpdexec to implement this in
mpdthumb.  When the --embedded option is supplied, the script will
first try readpicture, then albumart for each file specified.

2 years agompdexec: Add "verbose" option to print commands sent to MPD.
Nick Bowler [Sun, 25 Jul 2021 17:04:02 +0000 (13:04 -0400)]
mpdexec: Add "verbose" option to print commands sent to MPD.

In order to add readpicture support to the thumbnailer in addition to
albumart, we need a better way to distinguish which commands returned
what results from the server.

An easy way to do that is to just print the commands.

2 years agompdexec: Add support for readpicture command in download mode.
Nick Bowler [Sun, 25 Jul 2021 16:58:18 +0000 (12:58 -0400)]
mpdexec: Add support for readpicture command in download mode.

2 years agompdthumb: Fix compatibility with newer MPD versions.
Nick Bowler [Thu, 22 Jul 2021 03:46:50 +0000 (23:46 -0400)]
mpdthumb: Fix compatibility with newer MPD versions.

It seems that recent MPD servers have made backward-incompatible changes
to the albumart command.

Specifically, the cache check currently sends an absurdly huge offset to
avoid downloading a pointless and unnecessary multi-KB blob for every
image it is querying.  While this worked well with older servers, new
servers now reject such commands with an error instead of returning
useful information.

Fortunately, newer servers also implement the "binarylimit" command to
reduce the amount of data transferred.  For some reason we can't ask the
server to send less than 64 bytes but whatever, it is probably good
enough.

So work around the problem by testing whether the server supports
binarylimit, and use the new method if it does.  Otherwise use the
old method.  Command-line options are provided to force the behaviour
one way or the other (which avoids the extra round trip to the server).

3 years agompdreload: Handle playlist load errors better.
Nick Bowler [Tue, 5 Jan 2021 03:24:24 +0000 (22:24 -0500)]
mpdreload: Handle playlist load errors better.

When using the "load" command to load tracks from a stored playlist,
there is no guarantee that MPD will actually successfully load them.
This can occur, for example, if a playlist is created and then some
of the files in it are removed from the database.

Such failures are not reported directly by the protocol.  The "load"
command will succeed but you just get less tracks added to the play
queue.  This gets mpdreload confused as it no longer has an accurate
picture of the exact queue positions.

Solve this by querying the new queue length after tracks are loaded
from the playlist.  This allows mpdreload to determine the number of
failures and adjust the expected positions accordingly.

3 years agompdreload: Fix batch deletion when there are still loads pending.
Nick Bowler [Sun, 3 Jan 2021 21:12:49 +0000 (16:12 -0500)]
mpdreload: Fix batch deletion when there are still loads pending.

The batch deletion did not take into account the possibility that
some or all of the playlist may still need to be loaded afterwards
(this happens when there are tracks at the end of the target playlist
which are not in the current play queue).

This resulted in erroneous operation.  Fix that up.

And separate the batch loading into a separate routine to hopefully
clarify what the various track indices are so future me understands.

3 years agompdthumb: Add --help and --version options.
Nick Bowler [Fri, 19 Jun 2020 05:04:24 +0000 (01:04 -0400)]
mpdthumb: Add --help and --version options.

3 years agompdreload: Protocol optimizations.
Nick Bowler [Fri, 19 Jun 2020 05:01:39 +0000 (01:01 -0400)]
mpdreload: Protocol optimizations.

Try harder to send fewer commands to the MPD server.  In particular:

* We can submit commands to batch-load subranges from the target
  playlist into the play queue, then move them as a group into the
  final location.

* We don't need to send move commands for tracks that are already in
  the correct final position, which helps when reloading a playlist
  very similar to the current play queue.

* By arranging for all unwanted tracks to be shifted to the end of
  the play queue during the consolidation process, these can all be
  deleted with a single command.

3 years agompdreload: Simplify script operation.
Nick Bowler [Sat, 23 May 2020 20:33:30 +0000 (16:33 -0400)]
mpdreload: Simplify script operation.

This script doesn't need any metadata other than filenames and queue
IDs, so we don't need to store anything else in its data structures.

We can also ask MPD not to send us most unneeded information which
speeds things up a lot.

3 years agoFix print_usage file handle in the perl scripts.
Nick Bowler [Sat, 23 May 2020 20:33:25 +0000 (16:33 -0400)]
Fix print_usage file handle in the perl scripts.

Due to an off-by-one error all the perl scripts are printing the usage
line to standard error in the --help output, instead of standard output
as expected.  Fix that up.

3 years agoFactor out mpd_exec from some of the perl scripts.
Nick Bowler [Tue, 5 May 2020 04:41:14 +0000 (00:41 -0400)]
Factor out mpd_exec from some of the perl scripts.

The simple mpd_exec function can be easily moved into the MPDHacks
module.  Leave out the one in mpdexec.pl as it is more sophisticated
to handle things like binary downloads and probably not needed for
common code.

3 years agoFactor out MPD connection code.
Nick Bowler [Tue, 5 May 2020 03:01:06 +0000 (23:01 -0400)]
Factor out MPD connection code.

Instead of having three different copies of the MPD connection code in
the perl scripts, let's put it all in one place.  Now mpdreload is no
longer the only script that supports UNIX socket connections.

3 years agoFix quoting of single quotes in MPD protocol.
Nick Bowler [Sat, 2 May 2020 15:53:28 +0000 (11:53 -0400)]
Fix quoting of single quotes in MPD protocol.

Single quotes have to be quoted in the protocol, but were forgotten.

This is easy enough to fix but isn't helped by the fact that there
are three different copies of this bug on the perl side, so let's
split out that function into a new module and fix it there.

4 years agompdreload: New script to refresh MPD play queue from a playlist.
Nick Bowler [Fri, 20 Dec 2019 06:01:01 +0000 (01:01 -0500)]
mpdreload: New script to refresh MPD play queue from a playlist.

This script implements the effect of clearing the current play queue
and then loading a playlist, except that the play queue is not wiped
during the process which avoids losing playback state unnecessarily.

4 years agompdmenu: Pass top menu name into submenu generation.
Nick Bowler [Sun, 30 Jun 2019 14:41:08 +0000 (10:41 -0400)]
mpdmenu: Pass top menu name into submenu generation.

This enables names based on the original menu name to be generated.
Specifically, the KillMenuMPD function is now based on the original
menu name, and the toplevel album menu is now actually the same menu
as the corresponding entry in the artist menu.

4 years agompdmenu: Use MBIDs for track matching instead of name matching.
Nick Bowler [Sun, 30 Jun 2019 14:17:05 +0000 (10:17 -0400)]
mpdmenu: Use MBIDs for track matching instead of name matching.

Instead of guessing based on titles, match tracks by their work MBID.

This makes the title menu significantly simpler as we remove all the
title-specific special cases.  This approach gives results pretty close
to what we got originally (much better in some cases), but currently
things like different symphony movements which used to show up in the
menu are not handled.

4 years agompdmenu: Use MBIDs for artists instead of name matching.
Nick Bowler [Sat, 29 Jun 2019 19:16:37 +0000 (15:16 -0400)]
mpdmenu: Use MBIDs for artists instead of name matching.

This enables much more accurate artist menus, working properly with
variant spellings and whatnot.

4 years agompdmenu: Use MBIDs for albums instead of name matching.
Nick Bowler [Sat, 29 Jun 2019 16:04:05 +0000 (12:04 -0400)]
mpdmenu: Use MBIDs for albums instead of name matching.

This enables much more accurate album menus, e.g., fully distinguishing
between multiple versions of the same release that would previously be
merged together into a single display.

This also adjusts the album menu to use modern MPD database query
features, so we can correctly display all tracks from the album
regardless of the state of the play queue.

4 years agompdmenu: Restructure things a bit.
Nick Bowler [Fri, 28 Jun 2019 04:39:12 +0000 (00:39 -0400)]
mpdmenu: Restructure things a bit.

Restructure the basic program flow and update the top menu generation
using more helper functions and stuff, including a slight change to the
menu layout.  More to come.

4 years agompdmenu: Retrieve cover art from MPD.
Nick Bowler [Fri, 28 Jun 2019 03:09:00 +0000 (23:09 -0400)]
mpdmenu: Retrieve cover art from MPD.

Recent versions of MPD support retrieving cover art, which means we
(mostly) don't need to have the music directory mounted to poke around
in it.  Augment mpdexec with support for binary transfers in order to
retrieve this cover art, and implement a new thumbnailer script which
makes use of this functionality.

Mostly, because the function to launch geeqie in the scans directory
still requires poking in the music dir.  But all the menu images should
be displayed just from the connection to MPD now.

As a bonus, the new script is quite a bit faster than the old one, too.

4 years agompdmenu: Factor out thumbnail generation.
Nick Bowler [Fri, 28 Jun 2019 00:01:41 +0000 (20:01 -0400)]
mpdmenu: Factor out thumbnail generation.

Prep work for making use of MPD albumart, move all calls to the
thumbnailer into a single function, and adapt the menus to call
the function once to generate an entire list of cover art.

Drop the use of the --image option in the thumbnailer by poking at
the cover art directly, since this will no longer work with MPD
albumart.

4 years agompdmenu: Use FindBin module to locate auxiliary scripts.
Nick Bowler [Thu, 27 Jun 2019 23:18:12 +0000 (19:18 -0400)]
mpdmenu: Use FindBin module to locate auxiliary scripts.

With this separated from my FVWM config, the other scripts can be
located using FindBin assuming everything lives in the same directory.

4 years agoRelicense MPD scripts.
Nick Bowler [Thu, 27 Jun 2019 23:02:38 +0000 (19:02 -0400)]
Relicense MPD scripts.

It's the dawn of a new era.  I'm separating these scripts from my FVWM
configuration in preparation for some big overhauls.  Going forward,
as these are basically standalone programs in their own right we'll
be using the GNU General Public License.

(Leave thumbnail.zsh alone because the first order of business is to
kill it off).

4 years agoMPD script updates.
Nick Bowler [Sat, 20 Apr 2019 00:22:32 +0000 (20:22 -0400)]
MPD script updates.

Fix compatibility with latest perl which removes the 'encoding' pragma.

And improve mpdexec.pl to be a bit more flexible: command-line arguments
will be correctly quoted for MPD, and also add a mode to accept commands
on standard input which helps performance with long command sequences.

4 years agothumbnailer: Follow only one level of symbolic link.
Nick Bowler [Fri, 20 Oct 2017 01:39:17 +0000 (21:39 -0400)]
thumbnailer: Follow only one level of symbolic link.

Since my music is all in git annex now, the thumbnailer follows the
cover art symlinks all the way to the annex object directory.  This is
less than helpful, since the intention was to locate the album scan
directory.  Change the --image mode to just read the link once and
then stop.

4 years agoscripts: Add copyright header to thumbnail.zsh.
Nick Bowler [Tue, 4 Oct 2011 14:21:59 +0000 (10:21 -0400)]
scripts: Add copyright header to thumbnail.zsh.

4 years agompdmenu: Replace all uses of mpc with mpdexec.
Nick Bowler [Sun, 26 Feb 2012 19:39:52 +0000 (14:39 -0500)]
mpdmenu: Replace all uses of mpc with mpdexec.

May as well eliminate this dependency.

4 years agompdmenu: Use a specialized script to send playid commands to MPD.
Nick Bowler [Sun, 26 Feb 2012 19:35:54 +0000 (14:35 -0500)]
mpdmenu: Use a specialized script to send playid commands to MPD.

This avoids the dependency on a patched mpc.

4 years agompdmenu: Add support for classical movements to the title menu.
Nick Bowler [Tue, 9 Nov 2010 17:16:21 +0000 (12:16 -0500)]
mpdmenu: Add support for classical movements to the title menu.

4 years agompdmenu: Use geeqie instead of gqview.
Nick Bowler [Wed, 3 Nov 2010 14:23:09 +0000 (10:23 -0400)]
mpdmenu: Use geeqie instead of gqview.

4 years agoUse /usr/bin/env in zsh #! lines.
Nick Bowler [Thu, 6 Nov 2008 20:39:39 +0000 (15:39 -0500)]
Use /usr/bin/env in zsh #! lines.

4 years agoFix handling of & in FVWM menus.
Nick Bowler [Mon, 25 Aug 2008 04:04:15 +0000 (00:04 -0400)]
Fix handling of & in FVWM menus.

& is only magic in the _first_ field of an FVWM menu, hence it should only
be escaped in those circumstances.

4 years agompdmenu: Update title menu cases.
Nick Bowler [Sat, 2 Aug 2008 19:18:52 +0000 (15:18 -0400)]
mpdmenu: Update title menu cases.

4 years agompdmenu: Update title menu cases.
Nick Bowler [Thu, 31 Jul 2008 14:59:11 +0000 (10:59 -0400)]
mpdmenu: Update title menu cases.

4 years agompdmenu: Update title menu cases.
Nick Bowler [Tue, 22 Jul 2008 23:50:38 +0000 (19:50 -0400)]
mpdmenu: Update title menu cases.

4 years agompdmenu: remove whitespace at end of lines.
Nick Bowler [Sun, 1 Jun 2008 22:44:00 +0000 (18:44 -0400)]
mpdmenu: remove whitespace at end of lines.

4 years agompdmenu: don't bail out when MPD doesn't give us a songid.
Nick Bowler [Sun, 1 Jun 2008 22:43:09 +0000 (18:43 -0400)]
mpdmenu: don't bail out when MPD doesn't give us a songid.

This occurs when MPD is running, but hasn't played a song yet.  Make the
menu usable to start the player in this case.

4 years agoscripts: remove hardcoded music directory from thumbnail.zsh.
Nick Bowler [Fri, 30 May 2008 15:40:15 +0000 (11:40 -0400)]
scripts: remove hardcoded music directory from thumbnail.zsh.

Use a MUSIC environment variable and fall back to /home/music.  The fvwm
config sets this at startup.

4 years agoUpdate thumbnail.zsh to use zsh conventions.
Nick Bowler [Wed, 28 May 2008 19:23:37 +0000 (15:23 -0400)]
Update thumbnail.zsh to use zsh conventions.

4 years agothumbnail.sh should be thumbnail.zsh.
Nick Bowler [Wed, 28 May 2008 19:17:51 +0000 (15:17 -0400)]
thumbnail.sh should be thumbnail.zsh.

4 years agompdmenu: Use IO::Socket::INET6 to support IPv6 as well as IPv4.
Nick Bowler [Wed, 28 May 2008 13:56:43 +0000 (09:56 -0400)]
mpdmenu: Use IO::Socket::INET6 to support IPv6 as well as IPv4.

4 years agoFix stuff for systems without bash as /bin/sh
Nick Bowler [Thu, 8 May 2008 15:03:32 +0000 (11:03 -0400)]
Fix stuff for systems without bash as /bin/sh

4 years agoFix mpdmenu to work with the new scripts directory.
Nick Bowler [Sun, 20 Apr 2008 07:35:30 +0000 (03:35 -0400)]
Fix mpdmenu to work with the new scripts directory.

4 years agoMove scripts into their own subdirectory.
Nick Bowler [Sun, 20 Apr 2008 07:28:20 +0000 (03:28 -0400)]
Move scripts into their own subdirectory.

4 years agoInitial Commit.
Nick Bowler [Sun, 20 Apr 2008 05:42:55 +0000 (01:42 -0400)]
Initial Commit.