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.
+# Submit a command to the MPD server; each argument to this function
+# is quoted and sent as a single argument to MPD.
+sub exec {
+ my $cmd = join(' ', map { MPD::escape } @_);
+
+ print $sock "$cmd\n";
+}
+
my $mode = "top";
my %artistids;
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";
}
sub fvwm_cmd_unquoted {
print join(' ', @_), "\n";
}
my $entry;
foreach my $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/);
while (<$sock>) {
last if (/^OK/);
die($_) if (/^ACK/);
# Currently tracks are considered "related" if their associated recordings
# have at least one work in common.
sub get_tracks_by_track_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, $tagname) = (@_, "MUSICBRAINZ_RELEASETRACKID");
my %source;
my %matches;
my $entry;
return \%matches unless ($mbid);
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/);
while (<$sock>) {
last if (/^OK/);
die($_) if (/^ACK/);
my $entry;
return \%matches unless ($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/);
while (<$sock>) {
last if (/^OK/);
die($_) if (/^ACK/);
my $entry;
foreach my $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/);
while (<$sock>) {
last if (/^OK/);
die($_) if (/^ACK/);
my ($file) = @_;
my @results = ();
my ($file) = @_;
my @results = ();
- mpd_exec("playlistfind", "file", $file);
+ MPD::exec("playlistfind", "file", $file);
while (<$sock>) {
last if (/^OK/);
die($_) if (/^ACK/);
while (<$sock>) {
last if (/^OK/);
die($_) if (/^ACK/);
while (<$sock>) {
last if (/^OK/);
die($_) if (/^ACK/);
while (<$sock>) {
last if (/^OK/);
die($_) if (/^ACK/);
- mpd_exec("currentsong");
+ MPD::exec("currentsong");
while (<$sock>) {
last if (/^OK/);
die($_) if (/^ACK/);
while (<$sock>) {
last if (/^OK/);
die($_) if (/^ACK/);
-# 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";
-}
-
# Returns a hash reference containing all tracks in the current play queue.
# The hash keys are filenames.
sub get_tracks_in_play_queue {
my %matches;
my $entry;
# Returns a hash reference containing all tracks in the current play queue.
# The hash keys are filenames.
sub get_tracks_in_play_queue {
my %matches;
my $entry;
- mpd_exec("playlistinfo");
+ MPD::exec("playlistinfo");
while (<$sock>) {
last if /^OK/;
die($_) if /^ACK/;
while (<$sock>) {
last if /^OK/;
die($_) if /^ACK/;
my ($plname) = @_;
my @files;
my ($plname) = @_;
my @files;
- mpd_exec("listplaylist", $plname);
+ MPD::exec("listplaylist", $plname);
while (<$sock>) {
last if /^OK/;
die($_) if /^ACK/;
while (<$sock>) {
last if /^OK/;
die($_) if /^ACK/;
my $current = get_tracks_in_play_queue();
my $target = get_playlist_files($ARGV[0]);
my $current = get_tracks_in_play_queue();
my $target = get_playlist_files($ARGV[0]);
-mpd_exec("command_list_begin");
+MPD::exec("command_list_begin");
for (my $i = 0; $i < @$target; $i++) {
my $f = $target->[$i];
my $ids = $current->{$f}->{Id};
for (my $i = 0; $i < @$target; $i++) {
my $f = $target->[$i];
my $ids = $current->{$f}->{Id};
delete $current->{$f} unless (keys %$ids > 0);
if (defined $id) {
delete $current->{$f} unless (keys %$ids > 0);
if (defined $id) {
- mpd_exec("moveid", $id, $i);
+ MPD::exec("moveid", $id, $i);
- mpd_exec("addid", $f, $i);
+ MPD::exec("addid", $f, $i);
foreach (keys %$current) {
my $ids = $current->{$_}->{Id};
foreach (keys %$ids) {
foreach (keys %$current) {
my $ids = $current->{$_}->{Id};
foreach (keys %$ids) {
- mpd_exec("deleteid", $_);
+ MPD::exec("deleteid", $_);
-mpd_exec("command_list_end");
+MPD::exec("command_list_end");
while (<$sock>) {
last if /^OK$/;
die($_) if /^ACK/;
while (<$sock>) {
last if /^OK$/;
die($_) if /^ACK/;