Fue algo hecho en 10 minutos para no saber mucho o casi nada de Perl. Básicamente tomé el script de Audacious y XChat realizado por Milad Rastian y lo adapté tomando los comandos equivalentes para Banshee.
No agregué la ruta del archivo ya que Banshee lo muestra en formato URI, y queda feo con tantos caracteres como el %20 para los espacios y así. Lo que agregaré en la siguiente versión son el tiempo actual y el tiempo total de la canción, ya que Banshee lo muestra como segundos y no en el formato de minutos y segundos como lo hace Audacious. Así que en ese punto me tocará aprender cómo lo hace Perl para obtener esos datos y transformarlos.
Ya tengo la versión que muestra la duración actual y completa de la canción. Ahora se ahorró un poco más de código en la conversión de minutos y segundos para tratar de hacer más rápido el script (cosa que no veo que suceda, no entiendo por qué, espero que sea por el Banshee). Así mismo arreglé unas cosas para que no provocara errores este script para tan maravilloso reproductor.
Y sin más el código en bruto.
#!/usr/bin/perl -w # Banshee is now playing 0.1 Beta 3 # # (C) Copyright 2011 – David Kantun (Gargadon) # Agradecimientos a Milad Rastian ya que me basé en su script de Audacious # para crear un script compatible con Banshee. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA use POSIX qw(strftime); $script_name = "Banshee is now playing"; $script_version = "0.1b3"; $script_description = "Announces the current playing song information from Banshee in XChat."; $banshee_version = `banshee --version`; $banshee_version =~ s/Gnome\sbanshee\s//; chop $banshee_version; $bansheever = substr($banshee_version,0,21); IRC::register($script_name,$script_version,$script_description,""); IRC::print("Loaded \002".$script_name."\002:"); IRC::print("Use \002/banshee_help\002 to display a list of commands."); IRC::add_command_handler("banshee_announce","banshee_announce"); IRC::add_command_handler("banshee_next","banshee_next"); IRC::add_command_handler("banshee_prev","banshee_prev"); IRC::add_command_handler("banshee_play","banshee_play"); IRC::add_command_handler("banshee_pause","banshee_pause"); IRC::add_command_handler("banshee_version","banshee_version"); IRC::add_command_handler("banshee_help","banshee_help"); sub banshee_announce { if (`ps -C banshee` =~ /banshee/) { # Get current playing song information. $song_info = `banshee --hide-field --query-title `; chop $song_info; $artist_info = `banshee --hide-field --query-artist `; chop $artist_info; $album_info = `banshee --hide-field --query-album `; chop $album_info; $elapsed_info = `banshee --hide-field --query-position `; chop $elapsed_info; $total_info = `banshee --hide-field --query-duration `; chop $total_info; $bitrate= `banshee --hide-field --query-bit-rate `; chop $bitrate; $tiempoa=strftime("\%M:\%S", gmtime($elapsed_info)); $tiempob=strftime("\%M:\%S", gmtime($total_info)); IRC::command("/me \002is listening to:\002 ".$artist_info."\002 – \002".$song_info."\002 [\002".$album_info."\002] <> [\002".$tiempoa."\002/\002".$tiempob."\002] <> [\002".$bitrate." KB/s\002]"); } else { IRC::print("Banshee is not currently running."); } return 1; } sub banshee_next { # Skip to the next track. eval `banshee --next`; IRC::print("Skipped to next track."); return 1; } sub banshee_prev { # Skip to the previous track. eval `banshee --previous`; IRC::print("Skipped to previous track."); return 1; } sub banshee_play { # Start playback. eval `banshee --play`; IRC::print("Started playback."); return 1; } sub banshee_pause { # Pause playback. eval `banshee --pause`; IRC::print("Paused playback."); return 1; } sub banshee_version { # Display version information to a channel. IRC::command("/me is using ".$script_name." ".$script_version." with ".$bansheever." and XChat ".IRC::get_info(0)); return 1; } sub banshee_help { # Display help screen. IRC::print("\002\037".$script_name." Help:\037\002"); IRC::print(" \002About:\002"); IRC::print(" * Autor: David Kantun (Gargadon) "); IRC::print(" * URL: http://gargadon.teufansub.net/"); IRC::print(" * Script Version: ".$script_version); IRC::print(" * Banshee Version: ".$banshee_version); IRC::print(" * XChat Version: ".IRC::get_info(0)); IRC::print(" \002Commands:\002"); IRC::print(" * /banshee_announce – Display the current song playing to a channel."); IRC::print(" * /banshee_next – Skip to the next track."); IRC::print(" * /banshee_prev – Skip to the previous track."); IRC::print(" * /banshee_play – Start playback."); IRC::print(" * /banshee_pause – Pause playback."); IRC::print(" * /banshee_version – Display version information for the script, Banshee and XChat to a channel."); IRC::print(" * /banshee_help – Display this help screen."); return 1; }

Commentarios