summaryrefslogtreecommitdiff
path: root/plugins/mpd_client.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2013-03-11 11:31:28 +0100
committermathieui <mathieui@mathieui.net>2013-03-11 11:31:28 +0100
commite4f72d05c396851b2fa78534155bca9fab04f96f (patch)
tree94837c18276fdcf743720133884d08512e12cee2 /plugins/mpd_client.py
parentf11c15c0ceeddc61d712d23c86325f277691a59e (diff)
downloadpoezio-e4f72d05c396851b2fa78534155bca9fab04f96f.tar.gz
poezio-e4f72d05c396851b2fa78534155bca9fab04f96f.tar.bz2
poezio-e4f72d05c396851b2fa78534155bca9fab04f96f.tar.xz
poezio-e4f72d05c396851b2fa78534155bca9fab04f96f.zip
Send the tune only if ther is a change from the previous state
Diffstat (limited to 'plugins/mpd_client.py')
-rw-r--r--plugins/mpd_client.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/plugins/mpd_client.py b/plugins/mpd_client.py
index ae98b41b..9d64f449 100644
--- a/plugins/mpd_client.py
+++ b/plugins/mpd_client.py
@@ -23,6 +23,7 @@ class UpdateThread(threading.Thread):
def run(self, *args, **kwargs):
self.alive = True
+ current = None
while self.alive:
try:
self.c.connect(host=self.plugin.config.get('host', 'localhost'), port=self.plugin.config.get('port', '6600'))
@@ -35,11 +36,14 @@ class UpdateThread(threading.Thread):
status = self.c.status()
if status['state'] == 'play' and self.alive:
song = self.c.currentsong()
- self.xmpp.plugin['xep_0118'].publish_tune(artist=song.get('artist'),
- length=song.get('time'), title=song.get('title'),
- track=song.get('track'), block=False)
- else if status['state'] != 'play':
+ if current != song:
+ self.xmpp.plugin['xep_0118'].publish_tune(artist=song.get('artist'),
+ length=song.get('time'), title=song.get('title'),
+ track=song.get('track'), block=False)
+ current = song
+ elif status['state'] != 'play':
self.xmpp.plugin['xep_0118'].stop(block=False)
+ current = None
self.c.disconnect()
except:
pass