1
2
3
4
5
6
7
8
9
10
11 import os
12 import dbus
13 from GenericPlayer import GenericAPI
14 import urllib
15 from urlparse import urlparse
16
18 __name__ = 'Quodlibet'
19 __version__ = '0.1'
20 __author__ = 'Whise'
21 __desc__ = 'API to the Quodlibet Music Player'
22
23 ns = "net.sacredchao.QuodLibet"
24 playerAPI = None
25 shellAPI = None
26
27 callback_fn = None
28
29
30
33
35 if self.ns in dbus_iface.ListNames(): return True
36 else: return False
37
39 proxy_obj1 = self.session_bus.get_object(self.ns, '/net/sacredchao/QuodLibet')
40
41 self.playerAPI = dbus.Interface(proxy_obj1, self.ns)
42
43
45 try:
46 return self.playerAPI.CurrentSong()['title']
47 except:
48 return ''
50 try:
51 return self.playerAPI.CurrentSong()['album']
52 except:
53 return ''
54
56 try:
57 return self.playerAPI.CurrentSong()['artist']
58 except:
59 return ''
60
61
62
63
65
66
67 coverFile = os.environ["HOME"] + "/.quodlibet/current.cover"
68 if os.path.isfile(coverFile):
69 return coverFile
70 else:
71 current = os.environ["HOME"] + "/.quodlibet/current"
72 f = open(current, "r")
73 tmp = f.readlines(200)
74 f.close()
75 for line in tmp:
76 if line.startswith('~filename'):
77 t = line.replace('~filename=','')
78 t = t.split('/')
79 basePath = ''
80 for l in t:
81 if l.find('.') == -1:
82 basePath = basePath + l +'/'
83
84 names = ['Album', 'Cover', 'Folde']
85 for x in os.listdir(basePath):
86 if os.path.splitext(x)[1] in [".jpg", ".png"] and (x.capitalize()[:5] in names):
87 coverFile = basePath + x
88 return coverFile
89
90 return ''
91
93 if self.get_title() != '': return True
94 else: return False
95
98
101
104
111
112
113
114
115
116
117
118
119
120
123