Commits

Shlomi Fish committed a0e8fb4

Add more.

Comments (0)

Files changed (1)

t2/open-source/bits-and-bobs/nowplay-xchat.pl

 # use Xmms::Remote ();
 use Net::DBus ();
 
+use LWP::Simple qw(get);
+use XML::LibXML;
+
 IRC::register("Xmms Song Displayer", "1.0", "", "");
 IRC::add_command_handler("nowplay", "display_now_playing_song");
 
     {
         return;
     }
-    
+
     my $track_idx = $tracklist->GetCurrentTrack();
     if ($track_idx < 0)
     {
     }
     my $track = $tracklist->GetMetadata($track_idx);
     return
-        join(" - ", 
+        join(" - ",
             grep { lc($_) ne "unknown" }
             @{$track}{qw(artist title)}
         );
     chomp($artist);
     my $t = `dcop kaffeine KaffeineIface title`;
     chomp($t);
-    
+
     if ($artist || $t)
     {
         return "$artist - $t";
 
 =cut
 
+my $VLC_HTTP_PORT = 8080;
+
+sub get_vlc_title
+{
+    my $xml_text = get("http://127.0.0.1:${VLC_HTTP_PORT}/requests/status.xml");
+    if (defined ($xml_text)) {
+        my $dom = XML::LibXML->load_xml(string => $xml_text);
+        return $dom->findvalue(q#//info[@name='artist']#) . " - " .
+               $dom->findvalue(q#//info[@name='title']#);
+    }
+}
+
 sub display_now_playing_song
 {
-    my $title = get_amarok_dbus_title() || get_kaffeine_title() || get_amarok_title();
+    my $title = get_amarok_dbus_title() || get_vlc_title() || get_kaffeine_title() || get_amarok_title();
     IRC::command("/me is listening to $title");
 }