Skip to content

Instantly share code, notes, and snippets.

@proxypoke proxypoke/np_pp.py
Created Apr 28, 2013

Embed
What would you like to do?
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
You can’t perform that action at this time.