tool to play live365.com streams from the BSD terminal
authorThorsten Glaser <tg@mirbsd.org>
Sun, 23 Sep 2012 16:17:00 +0000 (18:17 +0200)
committerThorsten Glaser <tg@mirbsd.org>
Sun, 23 Sep 2012 16:25:32 +0000 (16:25 +0000)
mksh/L365 [new file with mode: 0644]

diff --git a/mksh/L365 b/mksh/L365
new file mode 100644 (file)
index 0000000..3754294
--- /dev/null
+++ b/mksh/L365
@@ -0,0 +1,43 @@
+#!/bin/mksh
+# $MirOS: contrib/hosted/tg/L365,v 1.2 2012/08/23 17:39:59 tg Exp $
+#-
+# Player for music streams from live365.com (not affiliated).
+
+# Inline-edit this script to define your credentials:
+USERID='myusername'
+PASSWD='my!secret!'
+
+# Code follows.
+
+# disabled as mpg123 with live365 is too unreliable (lack of caching)
+#if [[ $1 = -m ]]; then
+       player='mplayer -cache 128'
+#      shift
+#else
+#      player=mpg123
+#fi
+
+STATION=$1
+
+cd /
+if ! T=$(mktemp -d /tmp/L365.XXXXXXXXXX) || [[ ! -d $T/. ]]; then
+       print -u2 Error creating temporary directory.
+       exit 255
+fi
+
+cd "$T"
+if ! curl --cookie-jar curlcookies --output curldump --location-trusted \
+    "http://www.live365.com/cgi-bin/login.cgi?url=http://www.live365.com/index.live&membername=${USERID}&password=${PASSWD}"; then
+       cd /
+       rm -rf "$T"
+       print -u2 Error logging in.
+       exit 2
+fi
+
+SANE=$(fgrep SaneID curlcookies | cut -f7)
+SESS=$(fgrep sessionid curlcookies | cut -f7 | sed "s/${USERID}%3A//")
+
+cd /
+rm -rf "$T"
+
+exec $player "http://www.live365.com/play/${STATION}?SaneID=${SANE}&membername=${USERID}&session=${SESS}"