]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
Add bitrate and volume format directives
authorMikkel Kroman <redacted>
Wed, 20 Aug 2014 02:26:42 +0000 (04:26 +0200)
committerMikkel Kroman <redacted>
Wed, 20 Aug 2014 02:26:42 +0000 (04:26 +0200)
_data/scripts.yaml
scripts/mpd.pl

index 3303db7d77d594daef14c8d0f2cfe5d49fda3f1d..d79a183f69221e3c0075c960379e82fb6f762746 100644 (file)
   url: "http://wouter.coekaerts.be/irssi/"
   version: "1.0.0"
 
-- authors: "Erik Scharwaechter, Tobias Böhm"
-  contact: "diozaka@gmx.de, code@aibor.de"
+- authors: "Erik Scharwaechter, Tobias Böhm, Mikkel Kroman"
+  contact: "diozaka@gmx.de, code@aibor.de, mk@maero.dk"
   description: "print the song you are listening to"
   filename: "mpd.pl"
-  modified: "2014-08-09 13:19:26"
+  modified: "2014-08-20 04:23:10"
   license: "GPLv2"
   modules: "IO::Socket"
   name: "mpd"
-  version: "0.6"
+  version: "0.7"
 
 - authors: "Ricardo Mesquita"
   contact: "ricardomesquita@netcabo.pt"
index e0f8453bd10d08c795dacc8a7711de566c68f078..789bdafef44814b89f9f960e376a0ec933a2c701 100644 (file)
@@ -30,6 +30,7 @@
 #       Some minor changes                                            #
 #  0.6: Added some more format directives(time, album)                #
 #       Added support for password authentication                     #
+#  0.7: Added format directives for bitrate and volume                #
 #######################################################################
 
 use strict;
@@ -38,11 +39,11 @@ use Irssi;
 
 use vars qw{$VERSION %IRSSI %MPD};
 
-$VERSION = "0.6";
+$VERSION = "0.7";
 %IRSSI = (
           name        => 'mpd',
-          authors     => 'Erik Scharwaechter, Tobias Böhm',
-          contact     => 'diozaka@gmx.de, code@aibor.de',
+          authors     => 'Erik Scharwaechter, Tobias Böhm, Mikkel Kroman',
+          contact     => 'diozaka@gmx.de, code@aibor.de, mk@maero.dk',
           license     => 'GPLv2',
           description => 'print the song you are listening to',
          );
@@ -109,6 +110,8 @@ sub np {
     $MPD{'filename'} = "";
     $MPD{'elapsed'}  = "";
     $MPD{'total'}    = "";
+    $MPD{'volume'}   = "";
+    $MPD{'bitrate'}  = "";
 
     my $ans = "";
     my $str = "";
@@ -125,6 +128,10 @@ sub np {
         } elsif ($ans =~ /^time: (\d+):(\d+)$/) {
             $MPD{'elapsed'} = sprintf("%01d:%02d", $1/60,$1%60);
             $MPD{'total'} = sprintf("%01d:%02d", $2/60,$2%60);
+        } elsif ($ans =~ /^volume: (\d+)$/) {
+            $MPD{'volume'} = $1
+        } elsif ($ans =~ /^bitrate: (\d+)$/) {
+            $MPD{'bitrate'} = $1
         }
     }
 
@@ -165,6 +172,8 @@ sub np {
     $str =~ s/\%FILENAME/$MPD{'filename'}/g;
     $str =~ s/\%ELAPSED/$MPD{'elapsed'}/g;
     $str =~ s/\%TOTAL/$MPD{'total'}/g;
+    $str =~ s/\%BITRATE/$MPD{'bitrate'}/g;
+    $str =~ s/\%VOLUME/$MPD{'volume'}/g;
 
     if ($witem && ($witem->{type} eq "CHANNEL" ||
                    $witem->{type} eq "QUERY")) {
git clone https://git.99rst.org/PROJECT