Skip to content

Instantly share code, notes, and snippets.

@deepakjois
Forked from nonsleepr/futurelearn_dl.sh
Last active December 30, 2017 23:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save deepakjois/e2e75d3eabae3dc71253 to your computer and use it in GitHub Desktop.
Save deepakjois/e2e75d3eabae3dc71253 to your computer and use it in GitHub Desktop.
FutureLearn Video downloader (with aria2c and resume support)
#!/bin/bash
#
# Usage:
# > futurelearn_dl.sh login@email.com password course-name week-id
# Where *login@email.com* and *password* - your credentials
# ,*course-name* is the name from URL
# and *week-id* is the ID from the URL
#
# E.g. To download all videos from the page: https://www.futurelearn.com/courses/corpus-linguistics/todo/238
# Execute following command:
# > futurelearn_dl.sh login@email.com password corpus-linguistics 238
#
email=$1
password=$2
course=$3
weekid=$4
HD=/hd
# Pulls the login page and strips out the auth token
authToken=`curl -s -L -c cookies.txt 'https://www.futurelearn.com/sign-in' | \
ggrep -Po "(?<=authenticity_token\" value=\")([^\"]+)"`
function dlvid {
vzid=`curl -s -b cookies.txt $1 | ggrep -Po '(?<=video-)[0-9]+'`
vzurl=https://view.vzaar.com/${vzid}/download${HD}
aria2c -c $vzurl
}
# Posts all the pre-URI-encoded stuff and appends the URI-encoded auth token
curl -X POST -s -L -e 'https://www.futurelearn.com/sign-in' -c cookies.txt -b cookies.txt \
--data-urlencode email=$email \
--data-urlencode password=$password \
--data-urlencode authenticity_token=$authToken 'https://www.futurelearn.com/sign-in' > /dev/null
# Download Course page
curl -s -L -b cookies.txt https://www.futurelearn.com/courses/${course}/todo/${weekid} | \
ggrep -B8 'headline.*video' | ggrep -o '/courses[^"]*' | \
while read -r line; do
url=https://www.futurelearn.com${line}
dlvid $url
done
@abdulmaged82
Copy link

how i use this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment