Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
67 lines (39 sloc) 2.12 KB
This is a YouTube video downloader written in GNU Awk. It works well but
please don't take it too seriously. It's a proof of concept code, written to
see what can be done with GNU Awk's networking interface.
It was written by Peteris Krumins (
His blog is at -- good coders code, great reuse.
The code is licensed under the MIT license.
The code was written as a part of the article "Downloading YouTube Videos with
GNU Awk" on my website. The whole article can be read at:
Table of contents:
[1] Why did I write this program?
[2] How to use it?
One day I found out that the GNU implementation of Awk had added networking
support to Awk via a special filename that looks like this:
Since I love to explore obscure things and interesting language features, this
got me curious if I could write a YouTube downloader in Awk. This program is
the result of it.
The most challening parts in this project were:
1) How to do HTTP redirection?
I had to write a tiny HTTP protocol parser in Awk.
(see get_headers function)
2) How to do binary I/O?
Awk is not meant for binary I/O. It turned out I had to choose a random
character as the RS separator.
(see save_file function)
Specify the list of YouTube URLs as command arguments to get_youtube_vids.awk:
$ gawk -f get_youtube_vids.awk> [...]
This will download all the videos specified on the command line.
You can also specify just the YouTube video IDs:
$ gawk -f get_youtube_vids.awk ID1 ID2 ID3 ...
Happy downloading!
Peteris Krumins