]> git.ktnx.net Git - mpd-feeder.git/blobdiff - bin/mpd-feeder
proper mpd connection initialization
[mpd-feeder.git] / bin / mpd-feeder
index 827541fb9e9da1ef1e1a29ef221eb07f4ad52af5..f0ed182eb3a56dda8c191aaff5a345266ad78a6f 100755 (executable)
@@ -126,7 +126,7 @@ class Feeder {
     has $opt :reader;
     has $db;
     has $db_generation;
-    has $mpd;
+    has $mpd :reader;
 
 use constant DEFAULT_CONFIG_FILE => '/etc/mpd-feeder/mpd-feeder.conf';
 
@@ -150,11 +150,11 @@ use Net::Async::MPD;
         $opt->parse_command_line;
 
         unless ($opt->dump_config) {
-            $mpd = Net::Async::MPD->new(
-                host         => $opt->mpd_host,
-                port         => $opt->mpd_port,
-                auto_connect => 1,
-            );
+            my %conn = ( auto_connect => 1 );
+            $conn{host} = $opt->mpd_host if $opt->mpd_host;
+            $conn{port} = $opt->mpd_port if $opt->mpd_port;
+
+            $mpd = Net::Async::MPD->new(%conn);
 
             $self->connect_db;
             $self->update_db unless $self->opt->skip_db_update;