Last active
April 6, 2021 02:33
-
-
Save klardotsh/8234727 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 bash | |
die() { echo ""; exit; } | |
pidof cmus >/dev/null || die | |
statu=`cmus-remote -Q | grep status` | |
[ "${statu}" == "status playing" ] || die | |
stream=`cmus-remote -Q | grep file | grep http` | |
title=`cmus-remote -Q | grep -m 1 title | cut -d' ' -f3-` | |
artist=`cmus-remote -Q | grep -v aaa_mode | grep -v albumartist | grep -m 1 artist | cut -d' ' -f3-` | |
if [[ ! -z $stream ]]; then | |
streamURL=`echo ${stream} | cut -d' ' -f2` | |
streamData=`python2 ${HOME}/bin/shoutcast_meta.py ${streamURL} | cut -d"'" -f2` | |
if `echo ${title} | grep "cliqhop" > /dev/null`; then | |
title="soma.fm :: cliqhop" | |
else | |
if `echo ${title} | grep "public safety radio" > /dev/null`; then | |
title="soma.fm :: sf-1033" | |
else | |
if `echo ${title} | grep "Soma" > /dev/null`; then | |
title="soma.fm :: $(echo ${title} | cut -d':' -f1)" | |
fi | |
fi | |
fi | |
echo "${streamData} - ${title} " | |
else | |
echo "${artist} - ${title}" | |
fi |
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 python2 | |
import urllib2 | |
import sys | |
request = urllib2.Request(sys.argv[1]) | |
request.add_header('Icy-MetaData','1') | |
opener = urllib2.build_opener() | |
data=opener.open(request) | |
headers=True | |
while headers: | |
line = data.readline() | |
if line[0:11]=="icy-metaint": | |
interval = int(line[12:]) | |
if line=="\r\n": | |
headers=False | |
data.read(interval) | |
len=ord(data.read(1))*16 | |
#print "Meta data is",len | |
print data.read(len) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment