changeset 2773:cd9311fed796 trunk

[svn] A few more xchat-audacious.py corrections: - Oops. "return None" --> "return xchat.EAT_ALL" - Compacted the code a bit more.
author deitarion
date Wed, 16 May 2007 00:24:43 -0700
parents 3c2786bbcf36
children 57363f3ded79
files ChangeLog contrib/xchat-audacious.py src/audacious/build_stamp.c
diffstat 3 files changed, 19 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue May 15 23:53:07 2007 -0700
+++ b/ChangeLog	Wed May 16 00:24:43 2007 -0700
@@ -1,3 +1,14 @@
+2007-05-16 06:53:07 +0000  Stephen Sokolow <deitarion@gmail.com>
+  revision [4570]
+  Fixes for xchat-audacious.py:
+  - Added checks for DBusException (bad D-Bus or no Audacious)
+  - Fixed an off-by-one error that rendered /sendtrack's check for a username useless
+  - Removed some duplication
+  
+  trunk/contrib/xchat-audacious.py |   51 ++++++++++++++++++++++-----------------
+  1 file changed, 29 insertions(+), 22 deletions(-)
+
+
 2007-05-16 04:53:37 +0000  Ben Tucker <bnt@interchange.ubc.ca>
   revision [4568]
   -Renamed MPRIS /TrackList Shuffle method to Random
--- a/contrib/xchat-audacious.py	Tue May 15 23:53:07 2007 -0700
+++ b/contrib/xchat-audacious.py	Wed May 16 00:24:43 2007 -0700
@@ -6,7 +6,7 @@
 #   - support org.freedesktop.MediaPlayer (MPRIS)?
 #
 # This script is in the public domain.
-#   $Id: xchat-audacious.py 4570 2007-05-16 06:53:07Z deitarion $
+#   $Id: xchat-audacious.py 4572 2007-05-16 07:24:43Z deitarion $
 #
 
 __module_name__ = "xchat-audacious"
@@ -29,13 +29,10 @@
 def command_np(word, word_eol, userdata):
 	aud = get_aud()
 	if not aud:
-		return None
+		return xchat.EAT_ALL
 
-	# this seems to be best, probably isn't!
-	length = "stream"
-	if aud.SongLength(aud.Position()) > 0:
-		length = "%d:%02d" % (aud.SongLength(aud.Position()) / 60,
-				      aud.SongLength(aud.Position()) % 60)
+	length = aud.SongLength(aud.Position())
+	length = (length > 0) and ("%d:%02d" % (length / 60, length % 60)) or "stream"
 
 	xchat.command("SAY [%s | %d:%02d/%s]" % (
 		aud.SongTitle(aud.Position()).encode("utf8"),
@@ -46,10 +43,7 @@
 
 def makeVoidCommand(cmd):
 	def callback(word, word_eol, userdata):
-		aud = get_aud()
-		if not aud:
-			return None
-		getattr(aud, cmd)()
+		getattr(get_aud(), cmd, lambda: None)()
 		return xchat.EAT_ALL
 	return callback
 
@@ -66,7 +60,7 @@
 
 	aud = get_aud()
 	if not aud:
-		return None
+		return xchat.EAT_ALL
 
 	xchat.command('DCC SEND %s "%s"' % (word[1], aud.SongFilename(aud.Position()).encode("utf8")))
 	return xchat.EAT_ALL
@@ -79,4 +73,4 @@
 xchat.hook_command("PLAY", command_play, help="Begins playback.")
 xchat.hook_command("SENDTRACK", command_send, help="Sends the currently playing track to a user.")
 
-print "xchat-audacious $Id: xchat-audacious.py 4570 2007-05-16 06:53:07Z deitarion $ loaded"
+print "xchat-audacious $Id: xchat-audacious.py 4572 2007-05-16 07:24:43Z deitarion $ loaded"
--- a/src/audacious/build_stamp.c	Tue May 15 23:53:07 2007 -0700
+++ b/src/audacious/build_stamp.c	Wed May 16 00:24:43 2007 -0700
@@ -1,2 +1,2 @@
 #include <glib.h>
-const gchar *svn_stamp = "20070516-4568";
+const gchar *svn_stamp = "20070516-4570";