Skip to content

Instantly share code, notes, and snippets.

@d33tah
Created September 12, 2010 15:49
Show Gist options
  • Select an option

  • Save d33tah/576197 to your computer and use it in GitHub Desktop.

Select an option

Save d33tah/576197 to your computer and use it in GitHub Desktop.
#!/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