Skip to content

Instantly share code, notes, and snippets.

@mnstrspeed
Created December 7, 2015 16:27
Show Gist options
  • Save mnstrspeed/327e1a43ac09e67829b0 to your computer and use it in GitHub Desktop.
Save mnstrspeed/327e1a43ac09e67829b0 to your computer and use it in GitHub Desktop.
Download video lectures from TU Delft Collegerama (december 2015). Requires `wget`, `curl`, and `jq` (available in Ubuntu/Debian repositories).
#!/bin/bash
# resource ID of the video, can be obtained from the video URL:
# https://collegerama.tudelft.nl/Mediasite/Play/485dbc9fac81446bae6b2ba2fe0571ac1d?catalog=cf028e9a-2a24-4e1f-bdb5-2ace3f9cd42d
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
id=$1
SERVICE_ENDPOINT="https://collegerama.tudelft.nl/Mediasite/PlayerService/PlayerService.svc/json/GetPlayerOptions"
params="{\"getPlayerOptionsRequest\":{\"ResourceId\":\"${id}\",\"QueryString\":\"?catalog=cf028e9a-2a24-4e1f-bdb5-2ace3f9cd42d\",\"UseScreenReader\":false,\"UrlReferrer\":\"\"}}"
response=$(curl -s -X POST -H 'Content-Type: application/json' -d ${params} ${SERVICE_ENDPOINT})
title=$(echo "${response}" | jq '.d.Presentation.Title' -r)
airdate=$(echo "${response}" | jq '.d.Presentation.AirDate' -r)
presenters=$(echo "${response}" | jq '.d.Presentation.Presenters[].Name' -r)
echo "Thanks for the lecture, ${presenters}!\n"
video_urls=$(echo "${response}" | jq '.d.Presentation.Streams[].VideoUrls[].Location' -r)
for video_url in $video_urls
do
wget -nc "${video_url}" -O "${title}_${airdate}.mp4"
done
slide_base_url=$(echo "${response}" | jq '.d.Presentation.Streams[0].SlideBaseUrl' -r)
slide_filename_format=$(echo "${response}" | jq '.d.Presentation.Streams[0].SlideImageFileNameTemplate' -r)
slide_timing_file=${title}_${airdate}_slide_timing
rm ${slide_timing_file}
slides=$(echo "${response}" | jq '.d.Presentation.Streams[].Slides[]' -r -c)
for slide in $slides
do
time=$(echo "${slide}" | jq '.Time' -r)
nr=$(echo "${slide}" | jq '.Number' -r)
filename=$(echo $nr | xargs printf "slide_%.4d.jpg")
echo -ne "\rDownloading ${filename}"
wget -q -nc "${slide_base_url}/${filename}"
echo "${nr},${time},${filename}" >> $slide_timing_file
done
echo "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment