Skip to content

Instantly share code, notes, and snippets.

@shivamkr19
Last active February 4, 2022 09:48
Show Gist options
  • Save shivamkr19/1b964f64bfe04d9d54e0668c6223b765 to your computer and use it in GitHub Desktop.
Save shivamkr19/1b964f64bfe04d9d54e0668c6223b765 to your computer and use it in GitHub Desktop.
Download free egghead.io videos

Download free egghead.io videos

Download Egghead.io videos using Lynx Browser and youtube-dl. This method will only work for videos that do not require a pro account.

Prerequesits

You need a Unix/Linux box with Lynx console browser and Youtube-dl installed.

Lynx console Browser

Installation on Ubuntu(may require sudo)

$ apt-get install lynx

Installation on Fedora(may require sudo)

$ yum install lynx

Installation on Mac OS X(using homebrew)

$ brew install lynx

For all other Operating Systems, use your default package manager.

Youtube-dl

Official installation docs
https://rg3.github.io/youtube-dl/download.html
EDIT: Since HLS videos are segmented into many small parts and youtube-dl requires ffmpeg to convert videos, you also need ffmpeg as written on this page.

Downloading Video files

The following example should work for Linux and Mac.

$ url=https://egghead.io/courses/leverage-new-features-of-react-16
  • Use the below command to download all videos for a course or a given specific lesson depending on the URL you provided in last step.
# Old script had a lot of issues on os such as freeBSD and mac
# New script is as below : 
$ lynx -source $url | grep -o -e 'https://[^"]*.m3u8' | xargs -n1 youtube-dl -o "%(title)s.%(ext)s"

# You can also use CURL instead of lynx browser as in below script
$ curl -L $url | grep -o -e 'https://[^"]*.m3u8' | xargs -n1 youtube-dl -o "%(title)s.%(ext)s"

UPDATE: Doesn't work on Mac as pointed out in the comments by @toddzebert and others. Try solutions from Nithanaroy and mutalis instead.

@toddzebert
Copy link

grep and xargs have different options on Mac (as it's FreeBSD not GNU based), but while this modified code worked without error, it does not download the videos lynx -source $url | grep -E -o 'https?://[^"]*\.m3u8' | xargs -0 -n1 youtube-dl -o "%(title)s.%(ext)s"

ERROR: Unable to download webpage: (caused by URLError('no host given',))

@Y-Taras
Copy link

Y-Taras commented Oct 7, 2017

In Ubuntu this thing doesn't work either
screenshot from 2017-10-07 08 25 47

@DnyaneshwarWagh
Copy link

i got following error on Mac

lynx -source $url | ggrep -P -o 'https?://[^"]*\.m3u8' | gxargs -d '\n' -n1 youtube-dl -o "%(title)s.%(ext)s"

[generic] react-error-handling-using-error-boundaries-in-react-16-f429153da1: Requesting header
[generic] react-error-handling-using-error-boundaries-in-react-16-f429153da1: Downloading m3u8 information
ERROR: requested format not available

@smkamranqadri
Copy link

same error RROR: requested format not available

@FSerg
Copy link

FSerg commented Oct 9, 2017

The same problem:
[generic] react-error-handling-using-error-boundaries-in-react-16-f429153da1: Requesting header [generic] react-error-handling-using-error-boundaries-in-react-16-f429153da1: Downloading m3u8 information ERROR: requested format not available

@Nithanaroy
Copy link

Nithanaroy commented Oct 10, 2017

The above solution partially works for me on a macOS 10.9.5. Audio of the clips are missing :(

url=https://egghead.io/courses/leverage-new-features-of-react-16
brew install youtube-dl
brew install ffmpeg
brew install lynx
lynx -source $url | grep -o -e 'https[^"]*\.m3u8' | xargs -n1 youtube-dl -o "%(title)s.%(ext)s"


Got it completely working usingffmpeg
lynx -source $url | grep -o -e 'https[^"]*\.m3u8' > list.txt

And a small python script which reads the list.txt and saves the files using ffmpeg

import os

with open("./list.txt") as f:
	for i, line in enumerate(f):
		line = line.strip()
		print "Downloading %s file" % (i,)
		out_file_name = "_".join(line.split("/")[-1].split("-")[:-1])
		outname = "{}_{}.mp4".format(i, out_file_name)
		# print outname
		os.system("ffmpeg -i {} {}".format(line, outname))

@mutalis
Copy link

mutalis commented Oct 16, 2017

Use this command to download videos without using any additional script. @Nithanaroy @toddzebert @Shivamkrjha

lynx -source $url | grep -o -e 'https[^"]*.m3u8' | xargs -n1 youtube-dl -o "%(title)s.%(ext)s"

It worked with OSX High Sierra and youtube-dl 2017.10.15.1

@papidb
Copy link

papidb commented Oct 17, 2017

Said ffmpeg not installed on Ubuntu
Install ffmpeg on ubuntu.
sudo apt install ffmpeg

@npasparuhov
Copy link

Hello all, these tricks and hacks works only for free lessons.
Any idea how to get pro lessons without pay 200$ for pro account?

@lsimone
Copy link

lsimone commented Oct 22, 2017

I wrote a bash script that works (prerequisites: youtube-dl, lynx and ffmpeg):
https://gist.github.com/lsimone/4a334aca1a97ec41e56f42daf35e8cc6
It's a minimal quick 'n dirty implementation, but if you have any comment, just let me know.

@shivamkr19
Copy link
Author

@toddzebert
Your code runs perfectly fine on my FreeBSD system after dropping -0 from xargs.
For me, adding -0 back to xargs produces HTTP 403 Forbidden error followed by Error: Unable to download webpage from youtube-dl.

@phcostabh
Copy link

This snippet works on Mac and keep the files in order, prefixing them with "0x-", where x is the number of the episode. 😉

curl -sL $url \
    | grep -o -e 'https://[^"]*.m3u8' \
    | cat -n \
    | while read number file; do youtube-dl -o "$(printf "%02d" $number)-%(title)s.%(ext)s" $file; done

Copy link

ghost commented Jul 5, 2018

How to redownload course? I cannot redownload after canceled

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