Skip to content

Instantly share code, notes, and snippets.

@sdglhm
Last active July 12, 2017 12:45
Show Gist options
  • Save sdglhm/631494f43bb8d58d07afa085cdadab38 to your computer and use it in GitHub Desktop.
Save sdglhm/631494f43bb8d58d07afa085cdadab38 to your computer and use it in GitHub Desktop.

Lynda course downloader bash

Lynda course downloader is a bash script that I came up with to download lynda courses to my local computer so I could check them on the go. This uses Youtube-dl program which can be downloaded by running following command.

To download Youtube-dl

To install it right away for all UNIX users (Linux, OS X, etc.), type:

sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl

If you do not have curl, you can alternatively use a recent wget:

sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl

Also you'd need to have lynx browser installed.

yum install lynx -y
or
apt-get install lynx

To download Lynda course downloader,

wget -O lynda_dl.sh https://goo.gl/xqVVWc  
chmod +x lynda_dl.sh  
./lynda_dl.sh  

You will be asked with your lynda password and username. Provide them to continue. Then Copy lynda course page URL and past when asked. It will fetch URL's and start the download automatically. Open your terminal window to finish the download.

Enjoy !!!

#!/bin/bash
echo "Please enter your Lynda login username, followed by [ENTER]:"
read username
echo "Please enter your Lynda login password, followed by [ENTER]:"
read password
echo "Please enter your tutorial link to download, followed by [ENTER]:"
read dl_link
echo -e '\n\n\n'
echo "We will try to use account $username for downloading"
echo -e "\n\nTrying to get the URL list\n"
# Declaring URL process function
process_url (){
echo $1| cut -d '/' -f-4
}
lynx -listonly -dump $dl_link > link_list.txt
echo 'URL cleaning for scrape'
clean_url=$(process_url $dl_link)
echo $clean_url
grep $clean_url link_list.txt | cut -c 7- > link_list_clean.txt
echo 'URL list build complete'
echo -e '\n\n'
echo '--------------------------------'
echo 'STARTING DOWNLOAD PROCESS'
echo '--------------------------------'
while read in
do youtube-dl --flat-playlist --username $username --password $password --no-playlist $in
done < link_list_clean.txt
echo -e '\n\n\nDownload complete'
rm -f link_list.txt link_list_clean.txt
echo 'Cleared files'
echo 'Thank you for using Lynda download Bash'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment