Created
April 28, 2013 13:19
-
-
Save proxypoke/5476862 to your computer and use it in GitHub Desktop.
Display the currently playing song on Pingie Pie++!
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/env python3 | |
import time | |
import requests # pip install requests | |
import sh # pip install sh | |
MPD_HOST = "mpd.rzl" | |
SCROLL_WIDTH = 20 | |
def current(): | |
return str(sh.mpc("current", "--host", MPD_HOST, '-f', | |
'"%title%" by "%artist%" from "%album%"')) | |
def update(text): | |
requests.get("http://pingiepie.rzl:8000/{0}".format(text)) | |
def scroll(text): | |
n = 0 | |
while NotImplemented: | |
yield text[n:n + SCROLL_WIDTH] | |
n = (n + 1) % len(text) | |
def main(): | |
while NotImplemented: | |
song = current() | |
for line in scroll(song): | |
if song != current(): | |
break | |
update(line) | |
time.sleep(0.5) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment