Created
September 12, 2010 15:49
-
-
Save d33tah/576197 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| # -*- coding: utf-8 -*- | |
| import mpdclient2 | |
| from time import sleep | |
| from os import system | |
| hostname = 'localhost' | |
| port = 6600 | |
| password = '' | |
| params = {'host':hostname,'port':port} | |
| if password: | |
| password_dict = {'password':password} | |
| params = dict(params.items() + password_dict.items()) | |
| print params | |
| while 1: | |
| mpd = mpdclient2.connect(**params) | |
| oldtime = mpd.do.status().time | |
| oldsong = mpd.do.status().song | |
| sleep (60) | |
| newtime = mpd.do.status().time | |
| newsong = mpd.do.status().song | |
| if mpd.do.status().state == 'stop' or (mpd.do.status().state == 'play' | |
| and oldtime == newtime and oldsong == newsong): | |
| print mpd.do.status().state | |
| mpd.talker.putline('play') | |
| system("date") | |
| del(mpd) | |
| #EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment