X-Git-Url: http://git.draconx.ca/gitweb/mpdhacks.git/blobdiff_plain/e49c1f846176562de0978ba1cd445b50b1094a2d..b0f5f5741b234174958ade58a6e884df8b6b00e4:/mpdexec.pl diff --git a/mpdexec.pl b/mpdexec.pl index 8147f1d..496c558 100755 --- a/mpdexec.pl +++ b/mpdexec.pl @@ -20,7 +20,6 @@ decode_argv(Encode::FB_CROAK); binmode(STDOUT, ":utf8"); binmode(STDIN, ":utf8"); -use IO::Socket::INET6; use Getopt::Long qw(:config gnu_getopt); @@ -28,8 +27,6 @@ use FindBin; use lib "$FindBin::Bin"; use MPDHacks; -my $host = $ENV{MPD_HOST} // "localhost"; -my $port = $ENV{MPD_PORT} // 6600; my ($quiet, $binary, $ignore_errors, $download); sub print_version { @@ -77,8 +74,8 @@ EOF } GetOptions( - 'host|h=s' => \$host, - 'port|p=s' => \$port, + 'host|h=s' => \$MPD::host, + 'port|p=s' => \$MPD::port, 'quiet|q' => \$quiet, 'no-quiet' => sub { $quiet = 0; }, @@ -104,17 +101,7 @@ if ($binary) { } $quiet = 1 if (defined($binary) && $binary eq ""); -my $sock = new IO::Socket::INET6( - PeerAddr => $host, - PeerPort => $port, - Proto => 'tcp', -) or die "failed to connect to MPD: $!"; -#binmode($sock, ":utf8"); -binmode($sock); - -if (!(<$sock> =~ /^OK MPD ([0-9]+)\.([0-9]+)\.([0-9]+)$/)) { - die "MPD failed to announce version: $!"; -} +my $sock = MPD::connect(binmode => ":raw"); sub read_binary { my ($count) = @_;