1---
2layout: post
3title: Downloading courses from Linux Academy
4subtitle: youtube-dl is a phenomenal tool
5description: Using youtube-dl to pull Linux Academy courses for offline viewing
6tags: cli training
7date: 2019-10-19 01:35 -0400
8cover: /assets/posts/youtube-dl.png
9---
10# Forward
11Every month, Linux Academy releases courses for free. I'm a very busy college student and don't have time to whirl through everything I want to before it goes behind their paywall again so I figured out how to download a course or two every month using [`youtube-dl`](https://github.com/ytdl-org/youtube-dl/).
12
13# Setup
14* Install [`youtube-dl`](https://ytdl-org.github.io/youtube-dl/download.html)
15* Make sure you have a browser handy
16* Create a community account on [Linux Academy](https://linuxacademy.com/join/community)
17* Get some food
18* Maybe a drink
19* Sit back down in your chair
20* Spin around a bit
21* Read on
22
23# Downloading
24* Log into your account
25* Pick the course you want
26* Open the developer console and go to `Network` (Ctrl+Shift+E in Firefox)
27* You'll want to select `Media` as shown in the screenshot below
28
29
30
31* Click the video you want to start with
32* Watch the network logs
33* You'll see an entry that starts with `playlist` (screenshot below)
34
35
36
37* Right click it
38* Copy the URL
39* Paste it after `youtube-dl` in a terminal:
40
41```bash
42amolith@poseidon:~ $ youtube-dl https://video-cdn.linuxacademy.com/vods3/_definst_/smil:box/cdnstore/modules/lots-of-stuff-in-here
43```
44
45* Press enter
46* Watch the magic unfold
47
48At a high level, `youtube-dl` is acting like your browser and following the `m3u` playlist to download chunks of the file. After it fetches them all, it runs them through `ffmpeg` to stitch them together into a single video!
49
50I found it useful to open a text editor and script downloading a whole course at a time. All you have to do is type `youtube-dl -o` and copy/paste it however many times there are videos. Then, copy and paste the video title in quotes after `-o` and add `.mp4` to the end (command example below). After that, paste the URL. Do that with every video in the series, save the script, run `chmod +x <script>`, then `./<script>` and (after a bit) you'll have an entire course you can watch at your leasure!
51
52```bash
53amolith@poseidon:~ $ youtube-dl -o "04 - Conclusion and Next Steps.mp4" https://video-cdn.linuxacademy.com/vods3/_definst_/smil:box/cdnstore/modules/lots-of-stuff-here
54```
55
56**NOTE:** You may want to set up your directory structure beforehand so it's easier to script the process. Here's an example of one of mine:
57
58```bash
59amolith@poseidon:~/Videos/Courses/Ansible - Playbooks Deep Dive $ tree
60.
61├── 01 - Course Overview
62│ ├── 01 - About the Course.mp4
63│ ├── 02 - About the Training Architect.mp4
64│ ├── 03 - Course Features and Tools.mp4
65│ ├── 04 - About Ansible Playbooks.mp4
66│ └── 05 - Advanced Inventory Configuration.mp4
67├── 02 - Playbook Basics
68│ ├── 01 - Using YAML for Ansible Playbooks.mp4
69│ ├── 02 - Creating an Ansible Play.mp4
70│ ├── 03 - The ansible-playbook Command.mp4
71│ └── 04 - Understanding Playbook Tasks.mp4
72├── 03 - Essential Playbook Syntax
73│ ├── 01 - Using Variables in Playbooks.mp4
74│ ├── 02 - Working with Templates.mp4
75│ ├── 03 - Using Ansible Facts.mp4
76│ ├── 04 - Conditional Execution in Playbooks.mp4
77│ ├── 05 - Using Loops in Ansible.mp4
78│ └── 06 - Working with Handlers in Ansible.mp4
79├── 04 - Advanced Playbook Syntax
80│ ├── 01 - Executing Selective Parts of a Playbook.mp4
81│ ├── 02 - Working with Sensitive Data Using Ansible Vault.mp4
82│ ├── 03 - Error Handling in a Playbook: limit, ignore_errors, changed_when, and failed_when.mp4
83│ ├── 04 - Error Handling in a Playbook: Block Groups and The Debug Module.mp4
84│ ├── 05 - Asynchronous Tasks within a Playbook.mp4
85│ ├── 06 - Delegating Playbook Execution with delegate_to and local_action.mp4
86│ ├── 07 - Parallelism in Playbooks.mp4
87│ ├── 08 - Using run_once.mp4
88│ ├── 09 - Overview of Ansible Roles.mp4
89│ └── 10 - Ansible Role Demo.mp4
90└── 05 - Conclusion and Next Steps.mp4
91
924 directories, 26 files
93amolith@poseidon:~/Videos/Courses/Ansible - Playbooks Deep Dive $
94```