1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import time
- from mpd import MPDClient
- import lcd
- client = MPDClient()
- client.timeout = 60
- client.connect("localhost", 6600)
- def main():
- title = ""
- station = ""
- elapsed = ""
- while(True):
- stats = client.status()
- if elapsed == stats.get("elapsed", "0"):
- refresh(stats["song"])
- elapsed = stats.get("elapsed", "0")
- info = client.currentsong()
- if station != info.get("name", ""):
- station = info.get("name", "")
- print(station)
- lcd.write(station, title)
- if title != info.get("title", ""):
- title = info.get("title", "")
- print(title)
- lcd.write(station, title)
- time.sleep(10)
- def refresh(song):
- client.stop()
- time.sleep(1)
- client.play(song)
- if __name__ == "__main__":
- main()
|