forked from bobrathbone/piradio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
display_current.py
51 lines (41 loc) · 1.27 KB
/
display_current.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
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
#
# Diagnostic to Raspberry Pi Display current stream using MPD library
# $Id: display_current.py,v 1.6 2014/05/19 08:59:03 bob Exp $
#
# Author : Bob Rathbone
# Site : http://www.bobrathbone.com
#
# This program uses Music Player Daemon 'mpd' and the python-mpd library
# Use "apt-get install python-mpd" to install the Python MPD library
# See http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki
#
# License: GNU V3, See https://www.gnu.org/copyleft/gpl.html
#
# Disclaimer: Software is provided as is and absolutly no warranties are implied or given.
# The authors shall not be liable for any loss or damage however caused.
#
from mpd import MPDClient
client = MPDClient() # Create the MPD client
client.timeout = 10
client.idletimeout = None
client.connect("localhost", 6600)
currentsong = client.currentsong()
print ""
if len(currentsong) > 0:
for text in currentsong:
print text + ": " + str(currentsong.get(text))
current_id = int(currentsong.get("pos")) + 1
print "current_id", current_id
else:
print "No current song"
print ""
print "Status"
status = client.status()
for text in status:
print text + ": " + str(status.get(text))
print ""
stats = client.stats()
for text in stats:
print text + ": " + str(stats.get(text))
# End of program