Skip to content

Instantly share code, notes, and snippets.

@decke decke/orfradiodl.sh
Last active Sep 12, 2019

Embed
What would you like to do?
Download shows from OE1 Radio
#!/bin/sh
# Downloads shows from OE1
#
# Usage:
# ./orfradiodl.sh http://oe1.orf.at/programm/20180228/504777
#
# URL: https://gist.github.com/decke/672e63bee5001fe520aaf73502f095ae
parseJsonValue() {
KEY=$1
awk -F"[,:}]" '{for(i=1;i<=NF;i++){if($i~/'$KEY'\042/){print $(i+1)}}}' | tr -d '"' | sed -n 1p
}
DATE=`echo $1 | cut -d'/' -f5`
ID=`echo $1 | cut -d'/' -f6`
CHANNEL=`echo $1 | cut -d'/' -f3 | cut -d'.' -f1`
USERAGENT="Mozilla/5.0 (X11; Linux x86_64; rv:59.0) Gecko/20100101 Firefox/59.0"
JSONDATA=`curl -s -X GET https://audioapi.orf.at/${CHANNEL}/api/json/current/broadcast/${ID}/${DATE}`
LOOPSTREAMID=`echo "${JSONDATA}" | parseJsonValue loopStreamId`
TITLE=`echo "${JSONDATA}" | parseJsonValue title | sed 's/[^a-zA-Z 0-9-]//g'`
PROGRAM=`echo "${JSONDATA}" | parseJsonValue programTitle | sed 's/[^a-zA-Z 0-9-]//g'`
DOWNLOADURL="http://loopstream01.apa.at/?channel=${CHANNEL}&id=${LOOPSTREAMID}"
printf "CHANNEL:\t%s\nTITLE:\t\t%s\nPROGRAM:\t%s\nURL:\t\t%s\nJSON:\t%s\n" \
"${CHANNEL}" "${TITLE}" "${PROGRAM}" "${DOWNLOADURL}" "${JSONURL}"
curl -A "${USERAGENT}" -o "${CHANNEL} ${PROGRAM} ${TITLE} ${DATE}.mp3" "${DOWNLOADURL}"
@zkzkzk2015

This comment has been minimized.

Copy link

commented Mar 31, 2019

Schlüsselwort function mit () in Zeile 17 produziert Fehler. Einfach function löschen und alles funkt bestens.

@decke

This comment has been minimized.

Copy link
Owner Author

commented Sep 12, 2019

Danke, ist repariert!

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.