Skip to content

Instantly share code, notes, and snippets.

@leachim6
Created August 7, 2008 17:53
Show Gist options
  • Save leachim6/4453 to your computer and use it in GitHub Desktop.
Save leachim6/4453 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import web
import mpd
urls = (
'/(.*)', 'index'
)
class index:
def __init__():
client = mpd.MPDClient() # Init MPD Client
client.connect("localhost", 6600) # Connect to local MPD Server
cs = client.currentsong() # Get the currentsong dict
if 'title' in cs: # Check to see if "title" title exists in the dict
songtitle = cs['title'] # If it does set songtitle to the id3 title
elif 'file' in cs: # If it doesn't have a title use the filename
songtitle = cs['file'] # Set songtitle to the filename
songartist = " by "
songartist += cs['artist'] # Set songartist if the song has one
def GET(self, action):
i = web.input(times=1)
for c in range(int(i.times)):
print songtitle + songartist
if __name__ == "__main__": web.run(urls, globals())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment