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