X-Git-Url: https://git.draconx.ca/gitweb/mpdhacks.git/blobdiff_plain/b0f5f5741b234174958ade58a6e884df8b6b00e4..f0e74c3a1fc44153fe80961ff7de3b4a0786e5ea:/mpdmenu.pl diff --git a/mpdmenu.pl b/mpdmenu.pl index 4916d2a..3cc0e35 100755 --- a/mpdmenu.pl +++ b/mpdmenu.pl @@ -42,14 +42,6 @@ my ($topmenu, $menu); my $mode = "top"; my %artistids; -# Submit a command to the MPD server; each argument to this function -# is quoted and sent as a single argument to MPD. -sub mpd_exec { - my $cmd = join(' ', map { MPD::escape } @_); - - print $sock "$cmd\n"; -} - sub fvwm_cmd_unquoted { print join(' ', @_), "\n"; } @@ -281,7 +273,7 @@ sub get_tracks_by_work_mbid { my $entry; foreach my $mbid (@_) { - mpd_exec("search", "(MUSICBRAINZ_WORKID == \"$mbid\")"); + MPD::exec("search", "(MUSICBRAINZ_WORKID == \"$mbid\")"); while (<$sock>) { last if (/^OK/); die($_) if (/^ACK/); @@ -310,13 +302,13 @@ sub get_tracks_by_work_mbid { # Currently tracks are considered "related" if their associated recordings # have at least one work in common. sub get_tracks_by_track_mbid { - my ($mbid) = @_; + my ($mbid, $tagname) = (@_, "MUSICBRAINZ_RELEASETRACKID"); my %source; my %matches; my $entry; return \%matches unless ($mbid); - mpd_exec("search", "(MUSICBRAINZ_RELEASETRACKID == \"$mbid\")"); + MPD::exec("search", "(MUSICBRAINZ_RELEASETRACKID == \"$mbid\")"); while (<$sock>) { last if (/^OK/); die($_) if (/^ACK/); @@ -348,7 +340,7 @@ sub get_tracks_by_release_mbid { my $entry; return \%matches unless ($mbid); - mpd_exec("search", "(MUSICBRAINZ_ALBUMID == \"$mbid\")"); + MPD::exec("search", "(MUSICBRAINZ_ALBUMID == \"$mbid\")"); while (<$sock>) { last if (/^OK/); die($_) if (/^ACK/); @@ -380,7 +372,7 @@ sub get_releases_by_artist_mbid { my $entry; foreach my $mbid (@_) { - mpd_exec("search", "(MUSICBRAINZ_ARTISTID == \"$mbid\")"); + MPD::exec("search", "(MUSICBRAINZ_ARTISTID == \"$mbid\")"); while (<$sock>) { last if (/^OK/); die($_) if (/^ACK/); @@ -406,7 +398,7 @@ sub get_ids_by_filename { my ($file) = @_; my @results = (); - mpd_exec("playlistfind", "file", $file); + MPD::exec("playlistfind", "file", $file); while (<$sock>) { last if (/^OK/); die($_) if (/^ACK/); @@ -461,10 +453,10 @@ EOF } sub print_usage { - my $fh = $_[1] // *STDERR; + my ($fh) = (@_, *STDERR); print $fh "Usage: $0 [options]\n"; - print "Try $0 --help for more information.\n" unless (@_ > 0); + print $fh "Try $0 --help for more information.\n" unless (@_ > 0); } sub print_help { @@ -516,7 +508,7 @@ if ($mode eq "top") { $menu //= "MenuMPD"; - mpd_exec("status"); + MPD::exec("status"); while (<$sock>) { last if (/^OK/); die($_) if (/^ACK/); @@ -526,7 +518,7 @@ if ($mode eq "top") { } } - mpd_exec("currentsong"); + MPD::exec("currentsong"); while (<$sock>) { last if (/^OK/); die($_) if (/^ACK/);