-
-
Save klausenbusk/9ece67406f35def55169 to your computer and use it in GitHub Desktop.
Bash script to download "programs" (video) from dr.dk/tv (using dr.dk/mu-online api)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We need to look at bitrate... (VideoResource)