Created
August 7, 2008 17:54
-
-
Save leachim6/4454 to your computer and use it in GitHub Desktop.
This file contains 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/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