rendered paste body#! /usr/bin/env python__module_name__ = "DotSO"__module_version__ = "1.2"__module_description__ = "Script who display or send the current song(amarok)/video(kaffeine) to channel/user"import xchatimport commandsfrom urllib import unquotedef getamarok(cmd1): return commands.getoutput("dcop amarok default " + cmd1)def show_amarok(word, word_eol, userdata): def getamarok(cmd1): return commands.getoutput("dcop amarok default " + cmd1) command = '' status = getamarok('status') scrs = -1 if status == "2": scrs = 2 elif status == "1": scrs = 1 elif status == "0": scrs = 0 if scrs > 0 and len(word) > 1: if word[1] == 'send': try: command = 'dcc send ' + word[2] + ' "' + getamarok('path') + '"' scrs = -2 except: sendnick = xchat.get_info('channel') if sendnick[0] == "#": print "Imposible d'envoyer un fichier a tout un chan. Presiez un nick." elif sendnick == "(notices)" or sendnick == "(snotices)": print "Imposible d'envoyer un fichier a des PV de xchat" else: command = 'dcc send ' + sendnick + ' "' + getamarok('path') + '"' scrs = -2 else: print "Help is under construction" scrs = -2 elif scrs > 0: testalbum = getamarok('album') testartist = getamarok('artist') totaltime = getamarok('totalTime') album = sep1 = status = time = "" if testalbum != '': album = ' ( ' + testalbum + ' )' if testartist != '': sep1 = ' - ' if scrs == 1: status = " ( Pause )" if totaltime != "": time = " || " + getamarok('currentTime') + '/' + totaltime isplaying = testartist + album + sep1 + getamarok('title') position = getamarok('currentTime')+'/'+getamarok('totalTime') command = 'me is playing : ' + isplaying + time + status if scrs == 0: command = "me isn't playing ( Stop )" elif scrs == -1: print 'load amarok, or check that dcop is running.' else: print "Script error. Contact akane.mahoru@dot-world.net or Akane`Mahoru on #python-fr@irc.freenode.org" xchat.command(command) return xchat.EAT_ALL################## Kaffeine Part #########def show_kaffeine(word, word_eol, userdata): def getkaffeine(cmd1): return commands.getoutput("dcop kaffeine KaffeineIface " + cmd1) command = '' status = getkaffeine('isVideo') scrs = -1 if status == "true": scrs = 1 elif status == "false": scrs = 0 elif status == "call failed": scrs = -1 if scrs > 0 and len(word) > 1: if word[1] == 'send': try: command = 'dcc send ' + word[2] + ' "' + unquote(getkaffeine('getFileName')).replace('file:', '') + '"' scrs = -2 except: sendnick = xchat.get_info('channel') if sendnick[0] == "#": print "Imposible d'envoyer un fichier a tout un chan. Presiez un nick." elif sendnick == "(notices)" or sendnick == "(snotices)": print "Imposible d'envoyer un fichier a des PV de xchat" else: command = 'dcc send ' + sendnick + ' "' + unquote(getkaffeine('getFileName')).replace('file:', '') + '"' scrs = -2 else: print "Help is under construction" scrs = -2 elif scrs > 0: totaltime = int(getkaffeine('getLength')) def getime(): totaltime = int(getkaffeine('getLength')) timeM = totaltime / 60 timeS = ( float(totaltime) / 60 - timeM ) * 60 timeS2 = int(timeS) time = str(timeM) + "'" + str(timeS2) ftime = " ( " + str(time) + " ) " return str(ftime) position = getkaffeine('currentTime')+'/'+getkaffeine('totalTime') command = 'me is watching : ' + getkaffeine('title') + getime() if scrs == 0: command = "me isn't playing ( Stop )" elif scrs == -1: print 'load kaffeine, or check that dcop is running.' else: print "Script error. Contact akane.mahoru@dot-world.net or Akane`Mahoru on #python-fr@irc.freenode.org" xchat.command(command) return xchat.EAT_ALLxchat.hook_command("play", show_amarok)xchat.hook_command("playvideo", show_kaffeine)print 'DotSO succesfully loaded'