Skip to content

Instantly share code, notes, and snippets.

@proxypoke
Created April 28, 2013 13:19
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save proxypoke/5476862 to your computer and use it in GitHub Desktop.
Display the currently playing song on Pingie Pie++!
#!/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