Created
May 21, 2013 11:46
-
-
Save vonj/5619250 to your computer and use it in GitHub Desktop.
Play a stream (shoutcast or other) in mplayer, but display the song name in the title bar
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/python | |
import subprocess | |
import re | |
import sys | |
url = 'http://de.scenemusic.net/necta48.aac' | |
# Mods and chiptunes tunes often have too high stereo separation, soften it with | |
# panning: | |
p = subprocess.Popen(['mplayer', '-af-add', 'pan=2:0.8:0.5:0.5:0.8', url], | |
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, | |
bufsize=1) | |
for line in p.stdout: | |
if line.startswith('ICY Info:'): | |
info = line.split(':', 1)[1].strip() | |
attrs = dict(re.findall("(\w+)='([^']*)'", info)) | |
title = attrs.get('StreamTitle', '(none)') | |
sys.stdout.write("\x1b]2;" + title + "\x07") | |
print title | |
sys.stdout.flush() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment