Skip to content

Instantly share code, notes, and snippets.

@klausenbusk klausenbusk/drnuget Secret
Last active Dec 14, 2015

Embed
What would you like to do?
Bash script to download "programs" (video) from dr.dk/tv (using dr.dk/mu-online api)
#!/bin/bash
slug=$(echo "$1" | cut -f7 -d /)
programcard=$(curl --silent http://www.dr.dk/mu-online/api/1.0/programcard/"$slug")
function byte()
{
local byteoffset=$(echo ${!2} | grep -o --byte-offset "\"$1\":" | cut -f1 -d : | head -n 1)
echo ${!2} | cut -b $(($byteoffset+$(echo $1 | wc -c)))- | cut -f3 -d \" | head -n 1
}
Title=$(byte "Title" 'programcard' | sed "s/\( \?- \?\|: \| \|:\)/-/g")
BroadcastDate=$(byte "BroadcastDate" 'programcard')
VideoResource=$(byte "VideoResource\",\"Uri" 'programcard')
VideoResource=$(curl --silent --location "$VideoResource")
url=$(echo $VideoResource | grep -o '[0-9a-zA-Z/.,_-:]*.m3u8')
url=$(curl --silent $url | grep -v \# | head -n1)
for file in $(curl --silent $url | grep -v \#);
do
curl "$file" >> "$Title-$(date +%d-%b-%Y --date=$BroadcastDate).mp4"
done
@klausenbusk

This comment has been minimized.

Copy link
Owner Author

klausenbusk commented Apr 2, 2013

We need to look at bitrate... (VideoResource)

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.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.