rendered paste body#! /usr/bin/env python__module_name__ = "DotPlay"__module_version__ = "1.4"__module_description__ = "Script who display or send the current song(amarok)/video(kaffeine) to channel/user"import xchatfrom urllib import unquote################## AmaroK Part #########try: import pydcop def getamarok(cmd1): try: result = apply(pydcop.DCOPMethod("amarok", "default", cmd1)) except: result = -1 return resultexcept: import commands def getamarok(cmd1): return commands.getoutput("dcop amarok default " + cmd1)def show_amarok(word, word_eol, userdata): command = '' status = getamarok('status') if status == "call failed": status = -1 if status > 0 and len(word) > 1: if word[1] == 'send': try: command = 'dcc send ' + word[2] + ' "' + getamarok('path') + '"' status = -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') + '"' status = -2 else: print "Help is under construction" status = -2 elif status > 0: testalbum = getamarok('album') testtrack = getamarok('track') testartist = getamarok('artist') totaltime = getamarok('totalTime') currenttime = getamarok('currentTime') album = sep1 = pstatus = time = "" if testalbum != '': if testtrack != '': album = ' ( ' + testtrack + ". " + testalbum + ' )' else: album = ' ( ' + testalbum + ' )' if testartist != '': sep1 = ' - ' if status == 1: pstatus = " ( Pause )" if totaltime != "": if currenttime != "": time = " || " + getamarok('currentTime') + '/' + totaltime else: time = " || " + totaltime isplaying = testartist + album + sep1 + getamarok('title') position = getamarok('currentTime')+'/'+getamarok('totalTime') command = 'me is playing : ' + isplaying + time + pstatus elif status == 0: command = "me isn't playing" elif status == -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 #########try: import pydcop method = "module" def getkaffeine(cmd1): return apply(pydcop.DCOPMethod("kaffeine", "KaffeineIface", cmd1))except: import commands method = "command" def getkaffeine(cmd1): return commands.getoutput("dcop kaffeine KaffeineIface " + cmd1)def show_kaffeine(word, word_eol, userdata,command="",status=-3,kaffstatus=""): if method == "module": try: status = getkaffeine('isPlaying') except: status = -1 if method == "command": kaffstatus = getkaffeine('isPlaying') if kaffstatus == "true": status = 1 elif kaffstatus == "false": status = 0 elif kaffstatus == "call failed": status = -1 if status > 0 and len(word) > 1: if word[1] == 'send': try: command = 'dcc send ' + word[2] + ' "' + unquote(getkaffeine('getFileName')).replace('file:', '') + '"' status = -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:', '') + '"' status = -2 else: print "Help is under construction" status = -2 elif status > 0: totaltime = int(getkaffeine('getLength')) def getime(): Ttotaltime = int(getkaffeine('getLength')) TtimeM = Ttotaltime / 60 TtimeS = ( float(Ttotaltime) / 60 - TtimeM ) * 60 TtimeS2 = int(TtimeS) Ttime = str(TtimeM) + "'" + str(TtimeS2) Ntotaltime = int(getkaffeine('getTimePos')) NtimeM = Ntotaltime / 60 NtimeS = ( float(Ntotaltime) / 60 - NtimeM ) * 60 NtimeS2 = int(NtimeS) Ntime = str(NtimeM) + "'" + str(NtimeS2) ftime = " ( " + str(Ntime) + "/" + str(Ttime) +" ) " return str(ftime) command = 'me is watching : ' + getkaffeine('title') + getime() elif status == 0: command = "me isn't watching" elif status == -1: print 'load kaffeine, or check that dcop is running.' elif status == -3: 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)xchat.hook_command("playv", show_kaffeine)print 'DotPlay succesfully loaded'