переделанный скрипт для mocp (переделан из скрипта от амарока). Публикует вашу музыку с помощью gajim в jabber по pep tune . fuze

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# amarok_to_gajim_pep.py
#
# Copyright 2008 dicson <fominde@gmail.com>
# fuze 2010 - gajim_pep_mocp_now_playing.py
# 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.
import os, time, dbus.service
from dbus.mainloop.glib import DBusGMainLoop
class moctune(dbus.service.Object):
def __init__(self):
dbus.service.Object.__init__(self, dbus.SessionBus(), '/Player')
@dbus.service.signal(dbus_interface = 'org.freedesktop.MediaPlayer')
def TrackChange(self, trackinfo):
print (trackinfo['title'] + trackinfo['album'] + trackinfo['artist'])
def get_status():
f = os.popen("mocp -Q %state")
status = f.read()
return status
def get_data():
artist = album = title = ''
f = os.popen("mocp -Q %artist")
artist = f.read()
f = os.popen("mocp -Q %album")
album = f.read()
f = os.popen("mocp -Q %title")
title = f.read()
return title, artist, album
def set_status(title = '', artist = '', album = ''):
global lasttune
if lasttune == title + ' - ' + artist + ' - ' + album:
return
lasttune = title + ' - ' + artist + ' - '+ album
tune.TrackChange(dbus.Dictionary({'title' : title, 'artist' : artist, 'album' : album}))
dbus.SessionBus(mainloop = DBusGMainLoop())
lasttune = ''
tune = moctune()
try:
while 1:
status = get_status()
if 'PLAY' in status:
data = get_data()
set_status(data[0], data[1], data[2])
else:
set_status()
time.sleep(3)
except KeyboardInterrupt:
set_status()