stream fetcher
#!/usr/bin/bash | |
livestreamxml="http://www.srf.ch/webservice/ais/report/audio/withLiveStreams" | |
lines=$(curl -s www.srf.ch/sendungen/maloney | grep 'urn:srf:ais:audio:' | sed 's/\s*data-urn="urn:srf:ais:audio:\([a-zA-Z0-9-]*\).*/\1/ p') | |
readarray -t ids <<<"$lines" | |
nelems=${#ids[@]} | |
echo "Found $nelems streams." | |
if [[ $# -eq 1 ]]; then | |
sel=$1 | |
else | |
echo "Try downloading most recent stream." | |
sel=1 | |
fi | |
if [[ $sel -lt $nelems ]]; then | |
xmlfile="${livestreamxml}/${ids[${sel}]}.xml" | |
echo "xmlfile: $xmlfile" | |
xcontent=$(curl -s $xmlfile) | |
rtmpUrl=$(echo "${xcontent}" | grep rtmp | sed 's/<[\/a-zA-Z]*>//g') | |
title=$(echo "${xcontent}" | grep '/title' | head -n1 | sed -n 's/\s*<title>\(.*\)<.*/\1/ p') | |
date=$(echo "${xcontent}" | grep 'assetSetTitle' | sed -n 's/.*Maloney\s*vom\s*\([0-9]\{2\}\)\.\([0-9]\{2\}\)\.\([0-9]\{4\}\).*/\3-\2-\1/ p') | |
echo "title: $title" | |
echo "date: $date" | |
echo "streamurl: $rtmpUrl" | |
dst="${date}-${title// /_}.flv" | |
echo "dest: $dst" | |
rtmpdump -r $rtmpUrl -o $dst | |
else | |
echo "Invalid input: $0 id, where id=$1 " | |
echo "id must be <= $nelems." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment