File Coverage

blib/lib/Net/MPD.pm
Criterion Covered Total %
statement 43 159 27.0
branch 0 54 0.0
condition 11 33 33.3
subroutine 12 27 44.4
pod 6 7 85.7
total 72 280 25.7


line stmt bran cond sub pod time code
1             package Net::MPD;
2              
3 1     1   692 use strict;
  1         3  
  1         41  
4 1     1   8 use warnings;
  1         2  
  1         45  
5 1     1   314 use version 0.77;
  1         1932  
  1         8  
6              
7 1     1   81 use Carp;
  1         3  
  1         71  
8 1     1   381 use IO::Socket::INET;
  1         22169  
  1         9  
9 1     1   1128 use Net::MPD::Response;
  1         4  
  1         40  
10 1     1   9 use Scalar::Util qw'looks_like_number';
  1         3  
  1         76  
11              
12 1     1   32 use 5.010;
  1         5  
13              
14             our $VERSION = '0.07';
15              
16             =encoding utf-8
17              
18             =head1 NAME
19              
20             Net::MPD - Communicate with an MPD server
21              
22             =head1 SYNOPSIS
23              
24             use Net::MPD;
25              
26             my $mpd = Net::MPD->connect();
27              
28             $mpd->stop();
29             $mpd->clear();
30             $mpd->search_add(Artist => 'David Bowie');
31             $mpd->shuffle();
32             $mpd->play();
33             $mpd->next();
34              
35             while (1) {
36             my @changes = $mpd->idle();
37             print 'Changed: ' . join(', ', @changes) . "\n";
38             }
39              
40             =head1 DESCRIPTION
41              
42             Net::MPD is designed as a lightweight replacment for L which
43             depends on L and is no longer maintained.
44              
45             =cut
46              
47             sub _debug {
48 0 0   0   0 say STDERR @_ if $ENV{NET_MPD_DEBUG};
49             }
50              
51             sub _connect {
52 0     0   0 my ($self) = @_;
53              
54 0         0 my $socket;
55 0 0       0 if ($self->{hostname} =~ /\//) {
56             $socket = IO::Socket::UNIX->new($self->{hostname})
57 0 0       0 or croak "Unable to connect to $self->{hostname}";
58             } else {
59             $socket = IO::Socket::INET->new(
60             PeerHost => $self->{hostname},
61             PeerPort => $self->{port},
62 0 0       0 Proto => 'tcp',
63             ) or croak "Unable to connect to $self->{hostname}:$self->{port}";
64             }
65              
66 0         0 binmode $socket, ':utf8';
67              
68 0         0 my $versionline = $socket->getline;
69 0         0 my ($version) = ($versionline =~ /^OK MPD (\d+\.\d+\.\d+)$/);
70              
71 0 0       0 croak "Connection not to MPD" unless $version;
72              
73 0         0 $self->{socket} = $socket;
74 0         0 $self->{version} = qv($version);
75              
76 0 0       0 if ($self->{password}) {
77 0         0 my $result = $self->_send('password', $self->{password});
78 0 0       0 croak $result->message if $result->is_error;
79             }
80              
81 0         0 $self->update_status();
82             }
83              
84             sub _send {
85 0     0   0 my ($self, $command, @args) = @_;
86              
87 0         0 my $string = "$command";
88 0         0 foreach my $arg (@args) {
89 0         0 $arg =~ s/"/\\"/g;
90 0         0 $string .= qq{ "$arg"};
91             }
92 0         0 $string .= "\n";
93              
94             # auto reconnect
95 0 0       0 unless ($self->{socket}->connected) {
96 0         0 $self->_connect();
97 0         0 _debug '# Reconnecting';
98             }
99              
100 0         0 $self->{socket}->print($string);
101 0         0 _debug "> $string";
102              
103 0         0 my @lines = ();
104              
105 0         0 while (1) {
106 0         0 my $line = $self->{socket}->getline;
107 0 0       0 croak "Error reading line from socket" if not defined $line;
108 0         0 chomp $line;
109 0         0 _debug "< $line";
110              
111 0 0       0 if ($line =~ /^OK$|^ACK /) {
112 0         0 return Net::MPD::Response->new($line, @lines);
113             } else {
114 0         0 push @lines, $line;
115             }
116             }
117             }
118              
119             sub _require {
120 0     0   0 my ($self, $version) = @_;
121 0         0 $version = qv($version);
122 0 0       0 croak "Requires MPD version $version" if $version > $self->version;
123             }
124              
125             sub _inject {
126 93     93   259 my ($class, $name, $sub) = @_;
127 1     1   10 no strict 'refs';
  1         7  
  1         2989  
128 93         149 *{"${class}::$name"} = $sub;
  93         657  
129             }
130              
131             sub _attribute {
132 21     21   83 my ($class, $name, %options) = @_;
133              
134 21         68 (my $normal_name = $name) =~ s/_//g;
135              
136 21   66     115 $options{key} //= $normal_name;
137 21   66     97 $options{command} //= $normal_name;
138 21   100     83 $options{version} //= 0;
139              
140             my $getter = sub {
141 0     0   0 my ($self) = @_;
142 0         0 $self->_require($options{version});
143 0         0 return $self->{status}{$options{key}};
144 21         93 };
145              
146             my $setter = sub {
147 0     0   0 my ($self, $value) = @_;
148              
149 0         0 $self->_require($options{version});
150              
151 0         0 my $result = $self->_send($options{command}, $value);
152 0 0       0 if ($result->is_error) {
153 0         0 carp $result->message;
154             } else {
155 0         0 $self->{status}{$options{key}} = $value;
156             }
157              
158 0         0 return $getter->(@_);
159 21         84 };
160              
161             $class->_inject($name => sub {
162 0 0 0 0   0 if ($options{readonly} or @_ == 1) {
163 0         0 return $getter->(@_);
164             } else {
165 0         0 return $setter->(@_);
166             }
167 21         176 });
168             }
169              
170             my $default_parser = sub {
171             my $result = shift;
172              
173             my @items = ();
174             my $item = {};
175             foreach my $line ($result->lines) {
176             my ($key, $value) = split /: /, $line, 2;
177             if (exists $item->{$key}) {
178             push @items, 2 > keys %$item ? values %$item : $item;
179             $item = {};
180             }
181             $item->{$key} = $value;
182             }
183              
184             push @items, 2 > keys %$item ? values %$item : $item;
185              
186             return wantarray ? @items : $items[0];
187             };
188              
189             sub _command {
190 72     72   180 my ($class, $name, %options) = @_;
191              
192 72         257 (my $normal_name = $name) =~ s/_//g;
193              
194 72   66     406 $options{command} //= $normal_name;
195 72   50     351 $options{args} //= [];
196 72   66     281 $options{parser} //= $default_parser;
197              
198             $class->_inject($name => sub {
199 0     0     my $self = shift;
200 0           my $result = $self->_send($options{command}, @_);
201 0 0         if ($result->is_error) {
202 0           carp $result->message;
203 0           return undef;
204             } else {
205 0           return $options{parser}->($result);
206             }
207 72         431 });
208             }
209              
210             =head1 METHODS
211              
212             =head2 connect [$address]
213              
214             Connect to the MPD running at the given address. Address takes the form of
215             password@host:port. Both the password and port are optional. If no password is
216             given, none will be used. If no port is given, the default (6600) will be used.
217             If no host is given, C will be used.
218              
219             If the hostname contains a "/", it will be interpretted as the path to a UNIX
220             socket try to connect that way instead of using TCP.
221              
222             Return a Net::MPD object on success and croaks on failure.
223              
224             =cut
225              
226             sub connect {
227 0     0 1   my ($class, $address) = @_;
228              
229 0   0       $address ||= 'localhost';
230              
231 0           my ($pass, $host, $port) = ($address =~ /(?:([^@]+)@)?([^:]+)(?::(\d+))?/);
232              
233 0   0       $port ||= 6600;
234              
235 0           my $self = bless {
236             hostname => $host,
237             port => $port,
238             password => $pass,
239             }, $class;
240              
241 0           $self->_connect;
242              
243 0           return $self;
244             }
245              
246             =head2 version
247              
248             Return the API version of the connected MPD server.
249              
250             =cut
251              
252             sub version {
253 0     0 1   my $self = shift;
254 0           return $self->{version};
255             }
256              
257             =head2 update_status
258              
259             Issue a C command to MPD and stores the results in the local object.
260             The results are also returned as a hashref.
261              
262             =cut
263              
264             sub update_status {
265 0     0 1   my ($self) = @_;
266 0           my $result = $self->_send('status');
267 0 0         if ($result->is_error) {
268 0           warn $result->message;
269             } else {
270 0           $self->{status} = $result->make_hash;
271             }
272             }
273              
274             =head1 MPD ATTRIBUTES
275              
276             Most of the "status" attributes have been written as combined getter/setter
277             methods. Calling the L method will update these values. Only
278             the items marked with an asterisk are writable.
279              
280             =over 4
281              
282             =item volume*
283              
284             =item repeat*
285              
286             =item random*
287              
288             =item single*
289              
290             =item consume*
291              
292             =item playlist
293              
294             =item playlist_length
295              
296             =item state
297              
298             =item song
299              
300             =item song_id
301              
302             =item next_song
303              
304             =item next_song_id
305              
306             =item time
307              
308             =item elapsed
309              
310             =item bitrate
311              
312             =item crossfade*
313              
314             =item mix_ramp_db*
315              
316             =item mix_ramp_delay*
317              
318             =item audio
319              
320             =item updating_db
321              
322             =item error
323              
324             =item replay_gain_mode*
325              
326             =back
327              
328             =cut
329              
330             __PACKAGE__->_attribute('volume', command => 'setvol');
331             __PACKAGE__->_attribute('repeat');
332             __PACKAGE__->_attribute('random');
333             __PACKAGE__->_attribute('single', version => 0.15);
334             __PACKAGE__->_attribute('consume', version => 0.15);
335             __PACKAGE__->_attribute('playlist', readonly => 1);
336             __PACKAGE__->_attribute('playlist_length', readonly => 1);
337             __PACKAGE__->_attribute('state', readonly => 1);
338             __PACKAGE__->_attribute('song', readonly => 1);
339             __PACKAGE__->_attribute('song_id', readonly => 1);
340             __PACKAGE__->_attribute('next_song', readonly => 1);
341             __PACKAGE__->_attribute('next_song_id', readonly => 1);
342             __PACKAGE__->_attribute('time', readonly => 1);
343             __PACKAGE__->_attribute('elapsed', readonly => 1, version => 0.16);
344             __PACKAGE__->_attribute('bitrate', readonly => 1);
345             __PACKAGE__->_attribute('crossfade', key => 'xfade');
346             __PACKAGE__->_attribute('mix_ramp_db');
347             __PACKAGE__->_attribute('mix_ramp_delay');
348             __PACKAGE__->_attribute('audio', readonly => 1);
349             __PACKAGE__->_attribute('updating_db', key => 'updating_db', readonly => 1);
350             __PACKAGE__->_attribute('error', readonly => 1);
351              
352             sub replay_gain_mode {
353 0     0 0   my $self = shift;
354              
355 0 0         if (@_) {
356 0           my $result = $self->_send('replay_gain_mode', @_);
357 0 0         carp $result->message if $result->is_error;
358             }
359              
360 0           my $result = $self->_send('replay_gain_status');
361 0 0         if ($result->is_error) {
362 0           carp $result->message;
363 0           return undef;
364             } else {
365 0           return $result->make_hash->{replay_gain_mode};
366             }
367             }
368              
369             =head1 MPD COMMANDS
370              
371             The commands are mostly the same as the L
372             protocol|http://www.musicpd.org/doc/protocol/index.html> but some have been
373             renamed slightly.
374              
375             =head2 clear_error
376              
377             Clear the current error message in status. This can also be done by issuing any
378             command that starts playback.
379              
380             =head2 current_song
381              
382             Return the song info for the current song.
383              
384             =head2 idle [@subsystems]
385              
386             Block until a noteworth change in one or more of MPD's subsystems. As soon as
387             there is one, a list of all changed subsystems will be returned. If any
388             subsystems are given as arguments, only those subsystems will be monitored. The
389             following subsystems are available:
390              
391             =over 4
392              
393             =item database
394              
395             The song database has been changed after an update.
396              
397             =item udpate
398              
399             A database update has started or finished.
400              
401             =item stored_playlist
402              
403             A stored playlist has been modified.
404              
405             =item playlist
406              
407             The current playlist has been modified.
408              
409             =item player
410              
411             Playback has been started stopped or seeked.
412              
413             =item mixer
414              
415             The volume has been adjusted.
416              
417             =item output
418              
419             An audio output has been enabled or disabled.
420              
421             =item sticker
422              
423             The sticket database has been modified.
424              
425             =item subscription
426              
427             A client has subscribed or unsubscribed from a channel.
428              
429             =item message
430              
431             A message was received on a channel this client is watching.
432              
433             =back
434              
435             =head2 stats
436              
437             Return a hashref with some stats about the database.
438              
439             =head2 next
440              
441             Play the next song in the playlist.
442              
443             =head2 pause $state
444              
445             Set the pause state. Use 0 for playing and 1 for paused.
446              
447             =head2 play [$position]
448              
449             Start playback (optionally at the given position).
450              
451             =head2 play_id [$id]
452              
453             Start playback (optionally with the given song).
454              
455             =head2 previous
456              
457             Play the previous song in the playlist.
458              
459             =head2 seek $position $time
460              
461             Seek to $time seconds in the given song position.
462              
463             =head2 seek_id $id $time
464              
465             Seek to $time seconds in the given song.
466              
467             =head2 seek_cur $time
468              
469             Seek to $time seconds in the current song.
470              
471             =head2 stop
472              
473             Stop playing.
474              
475             =head2 add $path
476              
477             Add the file (or directory, recursively) at $path to the current playlist.
478              
479             =head2 add_id $path [$position]
480              
481             Add the file at $path (optionally at $position) to the playlist and return the
482             id.
483              
484             =head2 clear
485              
486             Clear the current playlist.
487              
488             =head2 delete $position
489              
490             Remove the song(s) in the given position from the current playlist.
491              
492             =head2 delete_id $id
493              
494             Remove the song with the given id from the current playlist.
495              
496             =head2 move $from $to
497              
498             Move the song from position $from to $to.
499              
500             =head2 move_id $id $to
501              
502             Move the song with the given id to position $to.
503              
504             =head2 playlist_find $tag $search
505              
506             Search the current playlist for songs with $tag exactly matching $search.
507              
508             =head2 playlist_id $id
509              
510             Return song information for the song with the given id.
511              
512             =head2 playlist_info [$position]
513              
514             Return song information for every song in the current playlist (or optionally
515             the one at the given position).
516              
517             =head2 playlist_search $tag $search
518              
519             Search the current playlist for songs with $tag partially matching $search.
520              
521             =head2 playlist_changes $version
522              
523             Return song information for songs changed since the given version of the current
524             playlist.
525              
526             =head2 playlist_changes_pos_id $version
527              
528             Return position and id information for songs changed since the given version of
529             the current playlist.
530              
531             =head2 prio $priority $position
532              
533             Set the priority of the song at the given position.
534              
535             =head2 prio_id $priority $id
536              
537             Set the priority of the song with the given id.
538              
539             =head2 shuffle
540              
541             Shuffle the current playlist.
542              
543             =head2 swap $pos1 $pos2
544              
545             Swap the positions of the songs at the given positions.
546              
547             =head2 swapid $id1 $id2
548              
549             Swap the positions of the songs with the given ids.
550              
551             =head2 list_playlist $name
552              
553             Return a list of all the songs in the named playlist.
554              
555             =head2 list_playlist_info $name
556              
557             Return all the song information for the named playlist.
558              
559             =head2 list_playlists
560              
561             Return a list of the stored playlists.
562              
563             =head2 load $name
564              
565             Add the named playlist to the current playlist.
566              
567             =head2 playlist_add $name $path
568              
569             Add the given path to the named playlist.
570              
571             =head2 playlist_clear $name
572              
573             Clear the named playlist.
574              
575             =head2 playlist_delete $name $position
576              
577             Remove the song at the given position from the named playlist.
578              
579             =head2 playlist_move $name $id $pos
580              
581             Move the song with the given id to the given position in the named playlist.
582              
583             =head2 rename $name $new_name
584              
585             Rename the named playlist to $new_name.
586              
587             =head2 rm $name
588              
589             Delete the named playlist.
590              
591             =head2 save $name
592              
593             Save the current playlist with the given name.
594              
595             =head2 count $tag $search ...
596              
597             Return a count and playtime for all items with $tag exactly matching $search.
598             Multiple pairs of $tag/$search parameters can be given.
599              
600             =head2 find $tag $search ...
601              
602             Return song information for all items with $tag exactly matching $search. The
603             special tag 'any' can be used to search all tag. The special tag 'file' can be
604             used to search by path.
605              
606             =head2 find_add $tag $search
607              
608             Search as with C and add any matches to the current playlist.
609              
610             =head2 list $tag [$artist]
611              
612             Return all the values for the given tag. If the tag is 'album', an artist can
613             optionally be given to further limit the results.
614              
615             =head2 list_all [$path]
616              
617             Return a list of all the songs and directories (optionally under $path).
618              
619             =head2 list_all_info [$path]
620              
621             Return a list of all the songs as with C but include metadata.
622              
623             =head2 search $tag $search ...
624              
625             As C but with partial, case-insensitive searching.
626              
627             =head2 search_add $tag $search ...
628              
629             As C but adds the results to the current playlist.
630              
631             =head2 search_add_pl $name $tag $search ...
632              
633             As C but adds the results the named playlist.
634              
635             =head2 update [$path]
636              
637             Update the database (optionally under $path) and return a job id.
638              
639             =head2 rescan [$path]
640              
641             As but forces rescan of unmodified files.
642              
643             =head2 sticker_value $type $path $name [$value]
644              
645             Return the sticker value for the given item after optionally setting it to
646             $value. Use an undefined value to delete the sticker.
647              
648             =cut
649              
650             sub sticker_value {
651 0     0 1   my ($self, $type, $path, $name, $value) = @_;
652              
653 0 0         if (@_ > 4) {
654 0 0         if (defined $value) {
655 0           my $result = $self->_send('sticker', 'set', $type, $path, $name, $value);
656 0 0 0       carp $result->message and return undef if $result->is_error;
657 0           return $value;
658             } else {
659 0           my $result = $self->_send('sticker', 'delete', $type, $path, $name);
660 0 0         carp $result->message if $result->is_error;
661 0           return undef;
662             }
663             } else {
664 0           my $result = $self->_send('sticker', 'get', $type, $path, $name);
665 0 0 0       carp $result->message and return undef if $result->is_error;
666              
667 0           my ($line) = $result->lines;
668 0           my ($val) = ($line =~ /^sticker: \Q$name\E=(.*)$/);
669 0           return $val;
670             }
671             }
672              
673             =head2 sticker_list $type $path
674              
675             Return a hashref of the stickers for the given item.
676              
677             =cut
678              
679             sub sticker_list {
680 0     0 1   my ($self, $type, $path) = @_;
681              
682 0           my $result = $self->_send('sticker', 'list', $type, $path);
683 0 0 0       carp $result->message and return undef if $result->is_error;
684              
685 0           my $stickers = {};
686 0           foreach my $line ($result->lines) {
687 0           my ($key, $value) = ($line =~ /^sticker: (.*)=(.*)$/);
688 0           $stickers->{$key} = $value;
689             }
690              
691 0           return $stickers;
692             }
693              
694             =head2 sticker_find $type $name [$path]
695              
696             Return a list of all the items (optionally under $path) with a sticker of the given name.
697              
698             =cut
699              
700             sub sticker_find {
701 0     0 1   my ($self, $type, $name, $path) = @_;
702 0   0       $path //= '';
703              
704 0           my $result = $self->_send('sticker', 'find', $type, $path, $name);
705 0 0 0       carp $result->message and return undef if $result->is_error;
706              
707 0           my @items = ();
708 0           my $file = '';
709              
710 0           foreach my $line ($result->lines) {
711 0           my ($key, $value) = split /: /, $line, 2;
712 0 0         if ($key eq 'file') {
    0          
713 0           $file = $value;
714             } elsif ($key eq 'sticker') {
715 0           my ($val) = ($value =~ /^\Q$name\E=(.*)$/);
716 0           push @items, { file => $file, sticker => $val };
717             }
718             }
719              
720 0           return @items;
721             }
722              
723             =head2 close
724              
725             Close the connection. This is pretty worthless as the library will just
726             reconnect for the next command.
727              
728             =head2 kill
729              
730             Kill the MPD server.
731              
732             =head2 ping
733              
734             Do nothing. This can be used to keep an idle connection open. If you want to
735             wait for noteworthy events, the C command is better suited.
736              
737             =head2 disable_output $id
738              
739             Disable the given output.
740              
741             =head2 enable_output $id
742              
743             Enable the given output.
744              
745             =head2 outputs
746              
747             Return a list of the available outputs.
748              
749             =head2 commands
750              
751             Return a list of the available commands.
752              
753             =head2 not_commands
754              
755             Return a list of the unavailable commands.
756              
757             =head2 tag_types
758              
759             Return a list of all the avalable song metadata.
760              
761             =head2 url_handlers
762              
763             Return a list of available url handlers.
764              
765             =head2 decoders
766              
767             Return a list of available decoder plugins, along with the MIME types and file
768             extensions associated with them.
769              
770             =head2 subscribe $channel
771              
772             Subscribe to the named channel.
773              
774             =head2 unsubscribe $channel
775              
776             Unsubscribe from the named channel.
777              
778             =head2 channels
779              
780             Return a list of the channels with active clients.
781              
782             =head2 read_messages
783              
784             Return a list of any available messages for this clients subscribed channels.
785              
786             =head2 send_message $channel $message
787              
788             Send a message to the given channel.
789              
790             =cut
791              
792             my $song_parser = sub {
793             my $result = shift;
794              
795             my @songs = ();
796             my $song = {};
797              
798             foreach my $line ($result->lines) {
799             my ($key, $value) = split /: /, $line, 2;
800              
801             if ($key =~ /^(?:file|directory|playlist)$/) {
802             push @songs, $song if exists $song->{type};
803             $song = { type => $key, uri => $value };
804             } else {
805             $song->{$key} = $value;
806             }
807             }
808              
809             return @songs, $song;
810             };
811              
812             my $decoder_parser = sub {
813             my $result = shift;
814              
815             my @plugins = ();
816             my $plugin = {};
817              
818             foreach my $line ($result->lines) {
819             my ($key, $value) = split /: /, $line, 2;
820              
821             if ($key eq 'plugin') {
822             push @plugins, $plugin if exists $plugin->{name};
823             $plugin = { name => $value };
824             } else {
825             push @{$plugin->{$key}}, $value;
826             }
827             }
828              
829             return @plugins, $plugin;
830             };
831              
832             __PACKAGE__->_command('clear_error');
833             __PACKAGE__->_command('current_song', parser => $song_parser);
834             __PACKAGE__->_command('idle');
835             __PACKAGE__->_command('stats');
836             __PACKAGE__->_command('next');
837             __PACKAGE__->_command('pause');
838             __PACKAGE__->_command('play');
839             __PACKAGE__->_command('play_id');
840             __PACKAGE__->_command('previous');
841             __PACKAGE__->_command('seek');
842             __PACKAGE__->_command('seek_id');
843             __PACKAGE__->_command('seek_cur');
844             __PACKAGE__->_command('stop');
845             __PACKAGE__->_command('add');
846             __PACKAGE__->_command('add_id');
847             __PACKAGE__->_command('clear');
848             __PACKAGE__->_command('delete');
849             __PACKAGE__->_command('delete_id');
850             __PACKAGE__->_command('move');
851             __PACKAGE__->_command('move_id');
852             __PACKAGE__->_command('playlist_find', parser => $song_parser);
853             __PACKAGE__->_command('playlist_id', parser => $song_parser);
854             __PACKAGE__->_command('playlist_info', parser => $song_parser);
855             __PACKAGE__->_command('playlist_search', parser => $song_parser);
856             __PACKAGE__->_command('playlist_changes', command => 'plchanges', parser => $song_parser);
857             __PACKAGE__->_command('playlist_changes_pos_id', command => 'plchangesposid');
858             __PACKAGE__->_command('prio');
859             __PACKAGE__->_command('prio_id');
860             __PACKAGE__->_command('shuffle');
861             __PACKAGE__->_command('swap');
862             __PACKAGE__->_command('swapid');
863             __PACKAGE__->_command('list_playlist', parser => $song_parser);
864             __PACKAGE__->_command('list_playlist_info', parser => $song_parser);
865             __PACKAGE__->_command('list_playlists');
866             __PACKAGE__->_command('load');
867             __PACKAGE__->_command('playlist_add');
868             __PACKAGE__->_command('playlist_clear');
869             __PACKAGE__->_command('playlist_delete');
870             __PACKAGE__->_command('playlist_move');
871             __PACKAGE__->_command('rename');
872             __PACKAGE__->_command('rm');
873             __PACKAGE__->_command('save');
874             __PACKAGE__->_command('count');
875             __PACKAGE__->_command('find', parser => $song_parser);
876             __PACKAGE__->_command('find_add');
877             __PACKAGE__->_command('list');
878             __PACKAGE__->_command('list_all', parser => $song_parser);
879             __PACKAGE__->_command('list_all_info', parser => $song_parser);
880             __PACKAGE__->_command('ls_info', parser => $song_parser);
881             __PACKAGE__->_command('search', parser => $song_parser);
882             __PACKAGE__->_command('search_add');
883             __PACKAGE__->_command('search_add_pl');
884             __PACKAGE__->_command('update');
885             __PACKAGE__->_command('rescan');
886             __PACKAGE__->_command('sticker');
887             __PACKAGE__->_command('close');
888             __PACKAGE__->_command('kill');
889             __PACKAGE__->_command('ping');
890             __PACKAGE__->_command('disable_output');
891             __PACKAGE__->_command('enable_output');
892             __PACKAGE__->_command('outputs');
893             __PACKAGE__->_command('config');
894             __PACKAGE__->_command('commands');
895             __PACKAGE__->_command('not_commands');
896             __PACKAGE__->_command('tag_types');
897             __PACKAGE__->_command('url_handlers');
898             __PACKAGE__->_command('decoders', parser => $decoder_parser);
899             __PACKAGE__->_command('subscribe');
900             __PACKAGE__->_command('unsubscribe');
901             __PACKAGE__->_command('channels');
902             __PACKAGE__->_command('read_messages');
903             __PACKAGE__->_command('send_message');
904              
905             1;
906              
907             =head1 TODO
908              
909             =head2 Command Lists
910              
911             MPD supports sending batches of commands but that is not yet available with this API.
912              
913             =head2 Asynchronous IO
914              
915             Event-based handling of the idle command would make this module more robust.
916              
917             =head1 BUGS
918              
919             =head2 Idle connections
920              
921             MPD will close the connection if left idle for too long. This module will
922             reconnect if it senses that this has occurred, but the first call after a
923             disconnect will fail and have to be retried. Calling the C command
924             periodically will keep the connection open if you do not have any real commands
925             to issue. Calling the C command will block until something interesting
926             happens.
927              
928             =head2 Reporting
929              
930             Report any issues on L
931              
932             =head1 AUTHOR
933              
934             Alan Berndt Ealan@eatabrick.orgE
935              
936             =head1 COPYRIGHT
937              
938             Copyright 2013 Alan Berndt
939              
940             =head1 LICENSE
941              
942             Permission is hereby granted, free of charge, to any person obtaining a copy of
943             this software and associated documentation files (the "Software"), to deal in
944             the Software without restriction, including without limitation the rights to
945             use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
946             of the Software, and to permit persons to whom the Software is furnished to do
947             so, subject to the following conditions:
948              
949             The above copyright notice and this permission notice shall be included in all
950             copies or substantial portions of the Software.
951              
952             THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
953             IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
954             FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
955             AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
956             LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
957             OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
958             SOFTWARE.
959              
960             =head1 SEE ALSO
961              
962             L, L
963              
964             =cut