#########################################################################
# Exaile Now Playing #
# Python Plugin For X-Chat #
# #
# Written by Sonic <sonic88@sonic88.org> #
# Modified by Cheesebaron <tomasz@ostebaronen.dk> #
#########################################################################
#! /usr/bin/env python
import xchat, dbus, string, random
__module_name__ = "Exaile np"
__module_version__ = "1.1"
__module_description__ = "Tell which song are you currently playing in exaile"
exa = ""
#phrases list. You can add more if you want to.
phrases = [
"say nope, I'm not telling you the song. nyah :P",
"me notes that this tagline has been censored on account of %s being, well.. listen!",
"me is currently listening to: %s",
"me is checking out %s",
"me is now playing %s",
"me pumps up the volume and spins up some %s",
"me jams along with %s",
"me vainly attempts to listen to %s and write code at the same time",
"me kicks back as the random DJ spins up a bottle of %s",
"me falls asleep in his chair and snores his way through a heartwarming rendition of %s",
"me pulls a CD from the stacks at random and listens to %s",
"me blows the dust off a copy of %s",
"me wakes up and starts pounding the alarmclock, which is blaring out %s",
"say ... and then Amarok pulled this out of the magic hat: %s",
"me cleans the wax out of his ears so he can hear the faint strains of %s",
"me rummages in the stacks and comes up with %s",
"me cranks up the volume on %s until ears bleed in neighboring countries @_@;;",
"say ahhhhhhhhhh here we go... %s",
"me dredges the bowels of the cutouts bin and comes up with %s",
]
random.shuffle(phrases)
print "Exaile Now Playing Plugin by Sonic <sonic@sonic88.org> loaded clean."
print "You can find me on irc: Sonic @ irc.azzurra.org"
def get_position():
global exa
return exa.current_position()
def get_length():
global exa
return exa.get_length()
def get_title():
global exa
return exa.get_title()
def get_artist():
global exa
return exa.get_artist()
def whatsplaying():
title = get_title()
artist = get_artist()
return "%s by %s" % ( title(), artist() )
def show_song(word, word_eol, userdata):
global exa
try:
bus = dbus.SessionBus()
obj = bus.get_object("org.exaile.DBusInterface","/DBusInterfaceObject")
exa = dbus.Interface(obj,"org.exaile.DBusInterface")
except:
print "Error during trying to comunicate with exaile!"
return xchat.EAT_ALL
if len(word) > 1:
if string.lower(word[1]) == "play":
exa.play()
elif string.lower(word[1]) == "pause":
exa.play_pause()
elif string.lower(word[1]) == "stop":
exa.stop()
elif string.lower(word[1]) == "next":
exa.next_track()
elif string.lower(word[1]) == "prev":
exa.prev_track()
elif string.lower(word[1]) == "vol-":
exa.decrease_volume(5)
elif string.lower(word[1]) == "vol+":
exa.increase_volume(5)
elif string.lower(word[1]) == "version":
print "Exaile Now Playing Plugin by \2Sonic\2 <sonic88@sonic88.org> version \2" + __module_version__ + "\2"
print "Exaile Version: \2" + str(exa.get_version()) + "\2"
elif string.lower(word[1]) == "help":
print "Exaile Now Playing Plugin for XChat HELP:"
print "Type \2/" + word[0] + "\2 to say what are you listening to."
print "Other Functions are:"
print "\2/" + word[0] + " play\2 to put your player in play mode."
print "\2/" + word[0] + " pause\2 to play/pause your player."
print "\2/" + word[0] + " stop\2 to stop your player."
print "\2/" + word[0] + " next\2 to go to the next track."
print "\2/" + word[0] + " prev\2 to go to the previous track."
print "\2/" + word[0] + " vol+\2 to increase the volume."
print "\2/" + word[0] + " vol-\2 to decrease the volume."
print "\2/" + word[0] + " version\2 to show plugin and player version."
print "\2/" + word[0] + " help\2 to show this help."
print "\2***\2 End Of Help \2***\2"
else:
print "Unknow command type: \2/" + word[0] + " help\2 for more information."
return xchat.EAT_ALL
try:
position = int(get_position())
except:
print "Error during trying to comunicate with exaile!"
return xchat.EAT_ALL
if not position:
print "Exaile is stopped or not running!"
return xchat.EAT_ALL
xchat.command ( random.choice(phrases) % whatsplaying() )
return xchat.EAT_ALL
xchat.hook_command("ex", show_song, help="/song Tell which song are you currently playing in exaile, /song help for more infos")
xchat.hook_command("exaile", show_song, help="/exaile Tell which song are you currently playing in exaile, /exaile help for more infos")