Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gitllermopalafox/dc9497049ff98049af81357b7ceb075b to your computer and use it in GitHub Desktop.
Save gitllermopalafox/dc9497049ff98049af81357b7ceb075b to your computer and use it in GitHub Desktop.
this script is to download egghead videos using youtube-dl

1. Requirements

In order for the bash script to work. you need to have youtube-dl installed on your system from here youtube-dl

2. Installation

2.1. Mac osx

You need the GNU version of getopt for this script to run.

2.1.1. Get GNU version of getopt:
brew install gnu-getopt
brew link --force gnu-getopt
2.1.2. Make it executable
chmod a+x download_egghead_videos.sh

2.2. Linux

2.2.1. Make it executable
chmod a+x download_egghead_videos.sh

3. Usage

usage: --coursename [--coursename "build-a-react-app-with-redux"] --type [--type "courses|lessons"]
3.1. Arguments

-c | --coursename: required parameter to supply the course name extracted from the url, i.e. https://egghead.io/courses/get-started-with-elasticsearch the --coursename would be 'get-started-with-elasticsearch'

-t | --type: required parameter to specify the type, either courses or lessons, extracted from the url as well.

Example

./download_egghead_videos.sh --coursename "build-virtual-reality-experiences-using-react-vr" --type "courses"
#!/bin/bash
usage() { echo "usage: --coursename [--coursename \"build-a-react-app-with-redux\"] --type [--type \"courses|lessons\"]" 1>&2; exit 1; }
OPTS=$(getopt -o c:t: --long coursename:,type: -n 'download_egghead_videos.sh' -- "$@")
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
eval set -- "$OPTS"
COURSENAME=""
TYPE=""
while true ; do
case "$1" in
-c | --coursename) COURSENAME="$2"; shift 2 ;;
-t | --type) TYPE="$2"; shift 2 ;;
-- ) shift; break ;;
* ) usage ;;
esac
done
if [ -z "${COURSENAME}" ] || [ -z "${TYPE}" ]; then
usage
fi
youtube-dl --download-archive "$COURSENAME/archive.txt" -o "$COURSENAME/%(playlist_index)s_%(title)s" "https://egghead.io/$TYPE/$COURSENAME"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment