forked from emesene/emesene-supported-plugins
/
handler_exaile.py
38 lines (33 loc) · 1.24 KB
/
handler_exaile.py
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
import songretriever
import DBusBase
class ExaileHandler(DBusBase.DBusBase):
'''Handler for exaile'''
NAME = 'Exaile'
DESCRIPTION = 'Music handler for exaile'
AUTHOR = 'Karasu'
WEBSITE = 'www.emesene.org'
def __init__(self, main_window = None,
iface_name = 'org.exaile.Exaile',
iface_path = '/org/exaile/Exaile'):
DBusBase.DBusBase.__init__(self, main_window, iface_name, iface_path)
def is_playing(self):
'''Returns True if a song is being played'''
if self.is_running():
track_info = str(self.iface.Query())
status = track_info.split(", ")[0]
if status == "status: playing":
return True
return False
def get_current_song(self):
'''Returns the current song in the correct format'''
if self.is_playing():
artist = self.iface.GetTrackAttr('artist')
if artist == None:
artist = ""
album = self.iface.GetTrackAttr('album')
if album == None:
album = ""
title = self.iface.GetTrackAttr('title')
if title == None:
title = ""
return songretriever.Song(artist, album, title)