Skip to content

Instantly share code, notes, and snippets.

@decke decke/orfradiodl.sh
Last active Mar 31, 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
DATE=`echo $1 | cut -d'/' -f5`
ID=`echo $1 | cut -d'/' -f6`
CHANNEL=`echo $1 | cut -d'/' -f3 | cut -d'.' -f1`
JSONURL="https://audioapi.orf.at/${CHANNEL}/api/json/current/broadcast/${ID}/${DATE}"
USERAGENT="Mozilla/5.0 (X11; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0"
function jsonValue() {
KEY=$1
num=$2
awk -F"[,:}]" '{for(i=1;i<=NF;i++){if($i~/'$KEY'\042/){print $(i+1)}}}' | tr -d '"' | sed -n ${num}p
}
LOOPSTREAMID=`curl -s -X GET ${JSONURL} | jsonValue loopStreamId 1`
TITLE=`curl -s -X GET ${JSONURL} | jsonValue title 1 | sed 's/[^a-zA-Z 0-9-]//g'`
PROGRAMTITLE=`curl -s -X GET ${JSONURL} | jsonValue programTitle 1 | sed 's/[^a-zA-Z 0-9-]//g'`
DOWNLOADURL="http://loopstream01.apa.at/?channel=${CHANNEL}&id=${LOOPSTREAMID}"
printf "CHANNEL:\t%s\nTITLE:\t%s\nPROGRAM:\t%s\nURL:\t%s\nJSON:\t%s\n" \
"${CHANNEL}" "${TITLE}" "${PROGRAMTITLE}" "${DOWNLOADURL}" "${JSONURL}"
curl -A "${USERAGENT}" -o "${CHANNEL} ${PROGRAMTITLE} ${TITLE}.mp3" "${DOWNLOADURL}"
@zkzkzk2015

This comment has been minimized.

Copy link

zkzkzk2015 commented Mar 31, 2019

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

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.