
Youtube-dl: Command-line program to download videos - axiomdata316
https://github.com/rg3/youtube-dl
======
EvanAnderson
I feel like the first rule of youtube-dl is not to talk about youtube-dl. I
keep expecting Google (and all the other sites it works on) to start taking
active measures to disable it. At some point YouTube is going to require an
EME module to play even "free" videos.

~~~
RachelF
Not everyone has fast enough bandwidth to watch live videos.

Many people rely on downloaders to actually watch the video.

~~~
naibafo
But they don't download the ads, so I doubt they matter very much as far as
google is concerned

~~~
zacmps
You can actually download the ads with YouTube-dl... I believe it's YouTube
only and still named as 'experimental', but theoretically it could be a
default to appease the big G.

~~~
savoytruffle
But surely they arrive as separate files, and not interspersed in the main
video. So it's implausible they'd ever be watched.

~~~
skinnymuch
Yes they would most likely arrive as separate files. Though YouTube-dl could
force their main codebase to merge the videos. Regardless from looking around
it doesn’t look like ads are downloaded.

------
mxfh
Since letting kids alone on youtube, is clusterf* of a nightmare, this is a
godsend tool to archive approved channels to a local media server.

This config file (with separate channel-list- and archive-files) template
found here, has proven quite useful to me combined with some minimal batch
job:

[https://www.reddit.com/r/DataHoarder/comments/858ny5/my_yout...](https://www.reddit.com/r/DataHoarder/comments/858ny5/my_youtubedl_config_downloading_entire_channels/)

~~~
robbrown451
Another option is to embed youtube videos on your own web page (hosted locally
or whatever). You don't need to download the actual videos, the ads tend to be
banners (not ones that make you wait to view it). Works great for my 4 year
old.

~~~
kennydude
Sometimes the ads can be very inapropiate for a 4 year old. I ended up
installing Adblock just for that.

~~~
robbrown451
Well they are only banner ads, not video ads. But I'll admit I pay $10 a month
for YouTube Red (actually they just renamed it Premium), which I get my moneys
worth since I don't have broadcast or cable tv or netflix.

------
nachtigall
The strength of youtube-dl is that – contradictionary to its name – there are
`extractors` for almost every streaming, video, tv or radio website:

[https://github.com/rg3/youtube-
dl/tree/master/youtube_dl/ext...](https://github.com/rg3/youtube-
dl/tree/master/youtube_dl/extractor)

I always use it to rip TV or radio shows from German public stations

~~~
madeofpalk
Reminds me of XBMC - Xbox Media Centre - (since renamed to Kodi) which runs on
much more than Xbox (if it even runs on Xbox any more at all...)

~~~
speps
It's now an UWP app, so it's full circle and runs on Xbox One.

------
rodorgas
When I want to download a video from a site I always think “it would be great
if youtube-dl worked with this niche website, but I think it’s too specific”,
then I try and it works, I’m always surprised.

~~~
Ajedi32
It's a pretty extensive list: [https://github.com/rg3/youtube-
dl/tree/master/youtube_dl/ext...](https://github.com/rg3/youtube-
dl/tree/master/youtube_dl/extractor)

------
sergiotapia
This may be my most favorite piece of software I have installed. Does what it
says on the tin, nothing more nothing less. LASER-focused, I really love that
about it.

mpv also comes close as great software.

~~~
BeetleB
Going off topic, but I must be one of those weird people who prefers mplayer
to mpv.

When watching a video, I like not knowing how long the video is. The OSD in
mpv spoils it for me. With mplayer, I can set in a config file to have OSD off
by default. Couldn't figure out how to do it with mpv. I think I had a few
other things in my config that isn't supported by mpv (and some where the mpv
team explicitly said they won't - mpv is mplayer without the bloat, after
all).

~~~
kqr
Huh, I wish I knew what you were talking about. I have used mpv for many years
now, and I have no OSD while watching -- only when pausing, seeking, and
otherwise interacting with it.

~~~
BeetleB
I should have clarified. I don't want OSD when seeking, pausing, etc. When
seeking, I get a glimpse of the progress bar. That will give me an idea of how
much is left.

------
superkuh
I've been using this ever since youtube dropped flash support. Early this year
youtube began throttling certain file formats and qualities. The way around
this is to call youtube-dl so that it uses an external downloader like,

\--external-downloader aria2c --external-downloader-args "-j 8 -s 8"

I wrap the entire thing up in some shell script as a .bashrc function which
takes a URL, touches the downloaded file (since youtube-dl saves the youtube
file modified date), then opens it in vlc.

~~~
pdkl95
When I tried using aria2 to work around the throttling you mentioned, I
noticed that simply using aria2 at all (no parallelism with -j/-s) fixed the
download rate. The primary difference was the User-Agent header; the standard
youtube-dl User-Agent[1] was throttled, but "aria2/1.30.0" was full speed.

The throttling also seemed to depend on which server was sending the file; a
bunch of recent uploads were throttled, while an obscure video from 8 years
ago with <100 views only had the usual small slow-start delay that was common
with videos that probably needed to be fetched completely uncached from from a
remote data center.

The throttling problem seemed to go away after a few weeks, and returned again
for a few hours a . Is it possible the "throttling" was actually some type of
bug or configuration error in Google's network and/or data archives?

[1] [https://github.com/rg3/youtube-
dl/blob/master/youtube_dl/uti...](https://github.com/rg3/youtube-
dl/blob/master/youtube_dl/utils.py#L85)

~~~
predakanga
It's been my experience that only the split audio/video streams are throttled
- it's possible that your obscure video didn't have those available for some
reason, meaning that you got the unthrottled combined file. You can force this
behaviour by using the "-f best" options, though that means you won't get
certain resolutions (1080p) or codecs (opus).

It's possible that this behaviour was designed to be pro-user; I can imagine a
circumstance where a DASH (Dynamic Adaptive Streaming over HTTP) client hit a
patch of network congestion, dropped to a lower quality, then the network
cleared up and it downloaded the rest of the video in low quality before it
could switch back. Throttling the speeds to just above the bitrate of the
video would solve that.

Mind you, that doesn't explain the user-agent targeting described in other
comments...

------
StavrosK
The most useful part of youtube-dl is that it works with mpv, so you just pass
a URL on the command line and MPV just plays the video in it.

I have two monitors, so I put a button on my Firefox toolbar to launch MPV
with the current URL, and configured MPV to start fullscreen on the second
monitor immediately and quit when done. It's made my video-watching experience
on the web an order of magnitude better.

~~~
muxator
Sincere curiosity: is there any advantage over playing full screen via a
browser?

I'm a heavy youtube-dl user and command line addicted myself, but cannot
imagine an advantage in using youtube-dl for live-playing a video, when using
the browser seems to give the same experience.

~~~
StavrosK
Yes, I would have to detach the browser window, move it to the other screen
(which is inconvenient because it has to go through a third screen), drop it,
fullscreen it, press play, and when it's done close the window.

Much more involved than a single click that never even has to open a new tab.

------
l5870uoo9y
I have an alias setup in my .bash_profile to easily download and save as .mp3
file:

> alias ymp3="youtube-dl --extract-audio --audio-format mp3"

~~~
krylon
Thank you! I did not even know it could do that!

~~~
lozf
Better to just grab the widely supported AAC (m4a) audio, than perform a lossy
to lossy transcode to mp3 if quality matters. For speech (lectures etc) low
bitrate Opus sounds great and saves space when/where it matters, but isn't as
widely compatible.

e.g. youtube-dl -f 140 "$URL"

------
shibel
I’ve actually used this one for quite a nifty Python script:

Invoke a Workflow from a YouTube video on my iPhone -> Dropbox file gets
appended with all the details of video -> Hazel is watching this file and
triggers the Python script -> which converts the video to MP3, slaps on
relevant tags and cover-art and uploads it to my iCloud Music Library [1].

So I can have an MP3 song on my iPhone minutes after I’ve watched the video on
YouTube.

[1] I do have Apple Music & Spotify [2], this is primarily for live/rare
versions, and piano covers that I like.

[2] need both for testing, “officialy” launching
[https://www.musicbutler.io](https://www.musicbutler.io) soon. /shamelessplug

~~~
xfer
A lot of anime/game music is not on any streaming service; so youtube-dl is
the only option.

~~~
BigJono
It's especially bad with games because music gets updated and changed all the
time. Official soundtracks often leave tracks out, take for example
Civilization V which has an official soundtrack with like 30 tracks, when the
game itself has more like 300. It's up to avid players of the game to compile
and document the full collection.

Game developers by and large don't give a shit if the musician's work is
preserved. If they don't make an effort then as far as I'm concerned they're
forfeiting their right to take issue with the morality of downloading their
game's music.

~~~
TAForObvReasons
> Game developers by and large don't give a shit if the musician's work is
> preserved. If they don't make an effort then as far as I'm concerned they're
> forfeiting their right to take issue with the morality of downloading their
> game's music.

That's a very slanted view of the situation. The game developers may not have
rights to distribute all of the music as a soundtrack (they would have to have
rights to distribute in the context of the game).

~~~
p1necone
In that case there's still noone losing out on potential sales. I don't see
why we should lose out on art being preserved just because rights issues
prevent it from being made available commercially.

------
TaylorAlexander
The program works on a huge list of streaming sites, not just YouTube. I
believe it started as a YouTube only thing and then grew.

Edit: Found the list of supported sites. [https://github.com/rg3/youtube-
dl/blob/master/docs/supported...](https://github.com/rg3/youtube-
dl/blob/master/docs/supportedsites.md)

------
lgeorget
A very useful and "secret" feature: you can give youtube-dl the URL of a
playlist instead of a single video and it will download all of them.

~~~
poisonarena
...and specify to only grab the videos as mp3's to download that perfect
song/mix playlist!

~~~
jsmthrowaway
Aspiring DJs do this, then play out the files they got from youtube-dl via
Serato or whatever, then every other minimally competent DJ in the room
immediately knows what’s happening based on how obviously shit it sounds.
Practice mixing in headphones and playing room scale PA are two different
ballgames, and when amplified, any youtube-dl format is as obvious to me as a
file being ripped from source vinyl. YouTube does more processing than people
realize, and it doesn’t take much ear for me to identify a pirated crate (even
beyond YouTube specifically).

If you spin and use youtube-dl to build a crate, we all know, and we don’t
respect you. You might win the crowd, but the people who actually bought into
their profession and contributed to the community are also in attendance, and
are very aware of your intrusion. You will quietly lose gigs without any
explanation, and assume promoters simply can’t see your genius until you’re
furiously working on 100 precious listens on SoundCloud. Fair use sampling? Go
nuts and clean it up after youtube-dl. Five minute record? Make a Beatport
account and get it overwith.

~~~
soundwave106
Now that's a strange rant. Not everyone who wants to download Youtube files to
MP3 is downloading electronic dance music for the purpose of playing it live
as a DJ.

In my personal case, it tends to be relatively obscure classical music. Due to
the "nature of the genre" there are quite a number of pieces that have never
been studio recorded and exist only in OTA radio recordings, or are only
available on long out-of-print vinyl, sometimes from foreign sources.

I honestly tend to prefer other sources other than Youtube personally and will
only plunk from there as a last resort (Youtube is a place that is more
"perishable" than others, which is why I Youtube-DL instead of just relying on
the stream), but Youtube has attracted some curators of recordings of this
sort.

~~~
jsmthrowaway
> Now that's a strange rant.

It’s called “expanding a conversation with additional perspective that most of
this audience is probably unfamiliar with,” including watching it happen to a
close friend who thought she could get away with it, but sure, interpret me as
angrily ranting at absolutely nobody in this audience because you skipped the
“if” that qualifies my pronouns in the part that made this thread upset and
would rather talk about your _much_ more interesting obscure classical
collection instead.

I love how stupid Hacker News thinks I am, and it’s telling me I’m on the
right track in the conduct of my life. Feeling’s mutual, rest assured.

------
voltagex_
Previously:

[https://news.ycombinator.com/item?id=8647943](https://news.ycombinator.com/item?id=8647943)
[https://news.ycombinator.com/item?id=11452765](https://news.ycombinator.com/item?id=11452765)

Some good discussion there.

------
toomanybeersies
Youtube-dl works with soundcloud as well, which is a useful feature.

It can even download playlists and albums.

It also has support for downloading images from Flickr, to an extent.

~~~
JackCh
Youtube-dl works with nearly everything. It's incredibly versatile.

------
eurticket
Please stop talking about this, I love how it is now!

~~~
QasimK
But if people didn’t talk about this, I would have have known that I could use
it to watch BBC iPlayer without going through the annoying login-wall!

~~~
Synaesthesia
Wow that’s really useful to know.

It also works for YouTube vids which are blocked in your country. :-)

~~~
crtasm
It does? I used it to grab a full series of an 90s movie reviews show and some
episodes were 'unavailable in your region'.

Some other episodes had the different error of unavailable due to copyright
claim by [various movie distributors].

~~~
Synaesthesia
It did work for me with cricket clips only available in India ..

------
bane
There's a stupid easy to use gui for this as well.

[https://github.com/MrS0m30n3/youtube-dl-
gui](https://github.com/MrS0m30n3/youtube-dl-gui)

------
martin-adams
One thing I wonder is how dependant other YouTube creators are in being able
to download YouTube videos so they can use it for commentary and parody. If
YouTube made that significantly harder, would some creators suffer?

~~~
JackCh
I bet most would start doing it with screen capture software/cards. I think
many already are.

------
JohnKacz
Gotta be careful sometimes. At least one tutorial video site I used it on
(where an account was needed) I was blocked and had to open a ticket to re-
enable my account by promising not to break their ToS which said something
explicit about not downloading a bunch of their videos. (I was using it on
whole courses and got flagged)

~~~
swyx
i mean... you were breaking the TOS though. that was a risk you presumably are
comfortable with.

~~~
jtbayly
I’m laughing at the thought of reading the Terms of Service. Anywhere.

~~~
batiudrami
knowing that downloading the videos/using them outside of what was expressly
intended by the provider would be against the TOS is pretty intuitive though,
no?

~~~
Dylan16807
I would not just assume that downloading courses I paid for is outside the
intended purpose.

------
beebmam
I think youtube-dl/archiver tools present some ethical problems.

If you're publishing something for commercial, do you have a right to one day
revoke that item you've published? I think many would say that no, you don't
have that right. Fair use and all that.

But if you're publishing your diary or some other personal items about your
life, not for something commercial, then I think many would argue that yes,
you should have that right. To have the right to make all data about you
disappear.

I'm pretty sure RMS explored these ethics before in some of his writings.

Personally, I'm a user of youtube-dl and have written some tools based on
cloud tech that helps me automate archival of all media I come across that I
find valuable. But I'm not so sure it's completely ethical in all cases.

~~~
JackCh
Do I have the right to go into peoples homes and root through their archived
correspondence to find and burn lengthy personal Christmas letters I once sent
them? If instead of writing a letter I made a video and sent them a link, and
they decided to keep the video around, that would be no different.

They would have no moral right to republish that letter/video, but I would
have no moral right to take their copy from them.

------
techntoke
One really cool feature from YouTube is automatic captioning. This creates
subtitles based on speech recognition for nearly any video. Here are the
settings in my mpv.conf that enables this:

    
    
      sub-font-size=32
      slang=en
      ytdl-raw-options=write-auto-sub=,sub-lang=en

------
rathish_g
I am not sure if this official version of a Youtube is available everywhere.
This will allow you to download youtube videos and even share them without the
internet.

[https://play.google.com/store/apps/details?id=com.google.and...](https://play.google.com/store/apps/details?id=com.google.android.apps.youtube.mango&hl=en_IN)

Youtube for Kids is another app which is kid-friendly

[https://play.google.com/store/apps/details?id=com.google.and...](https://play.google.com/store/apps/details?id=com.google.android.apps.youtube.kids&hl=en)

------
adamnemecek
I’m particular to jdownloader.
[http://jdownloader.org](http://jdownloader.org) Works on so many downloading
services and also YouTube.

~~~
colejohnson66
I like JDownloader, but it comes with adware and other things in its
installer.

~~~
wp381640
Run it on docker, I use jlesage/jdownloader-2

~~~
rekado
How does the problem of running some untrustworthy code get better by adding
even more binaries?

Is the goal just to use the kernel's process isolation features that you can
access with `unshare`?

Or do you mean to just bypass the installation step (because that purportedly
contains adware)?

------
palad1n
I tried downloading a video I purchased on Youtube but what got retrieved I
could not view. The DRM seems to have prevented this from working.

~~~
caractacus
What was the video?

------
ggm
I have a command sequence which is:

1) find something I like is not released in my economy to buy as an MP3 2)
find a low(ish)fi video of the original artist playing it at some awesome gig
you wish you could go to with the time machine 3) use youtube-dl to dl it,
then post process into an mp3 or m4a 4) enjoy listening to glenn gould
humming, or keith jarrett humming, or that time the bomb landed next to the
string quartet playin in london in 1940, or the one where the film clip of
lena horne singing 'stormy weather' is just the perfect version...

I know that i'm outside the rules, but if they don't do something to let me
pay for the IPR, but do put a video up free to air, I'm kind-of confused at
this point: If I put dark glasses on, while I "watched" the youtube isn't it
the same?

------
ryuuchin
There's also ytdl integration in mpv[1]. The excellent open source media
player. So anything you can download with ytdl you can stream in mpv.

[1] [https://mpv.io](https://mpv.io)

~~~
jamklda
MPC-BE has Youtube-dl integration aswell

[https://sourceforge.net/projects/mpcbe/](https://sourceforge.net/projects/mpcbe/)

------
jaimehrubiks
I created a somehow complete gui for youtube-dl, It is opensource in github
and has a combination of youtube-dl, ffmpeg and mpv player. Written in java.
It is called musicboo and I programmed it after learning java in my
university. It has been working for some years perfectly with the automatic
youtube-dl update system, although I have moved my backend many times
preserving a domain.

[http://musicboo.hontzakdio.com/](http://musicboo.hontzakdio.com/)

------
alde
A cool fact is that mpv can hook into youtube-dl to play videos by youtube
url. I use this a lot for music and 4k videos (mpv unlike browsers has good
gpu decoding support on linux).

------
sevrex
I've been using this for years and it is absolutley excellent

------
starmole
See also:
[https://www.jwz.org/hacks/youtubedown](https://www.jwz.org/hacks/youtubedown)

------
rocky1138
Little-known but very helpful feature of Youtube-dl: paste a URL to a playlist
in, and it'll dutifully download every video in the playlist.

~~~
JackCh
It's helpful to use

    
    
        -i, --ignore-errors
    

When doing that. By default, if a playlist contains a single video that's no
longer available, youtube-dl will stop downloading the playlist when it hits
that video.

When playing a youtube playlist in mpv with youtube-dl, sometimes --load-
unsafe-playlists is needed. This is rare however.

------
xab9
I'm using a node version: [https://github.com/fent/node-
ytdl](https://github.com/fent/node-ytdl)

The only bug I found is that name escaping sometimes breaks, but I usually
name things manually. Ffmpeg audio conversion needs to be done manually, but
that's just an extra line.

------
shmerl
youtube-dl does a good job of merging DASH streams into proper media files.

It can also parse various audio sites, and I think it's what mpv is using for
Bandcamp for example.

Try this:

    
    
        mpv https://danielamosboots.bandcamp.com/track/triangle-square

------
etaioinshrdlu
The elephant in the room is obviously that this is probably illegal under
DMCA.

~~~
JackCh
If by _" elephant in the room"_ you mean _" something nobody gives a single
shit about."_ Seriously, why should I care?

Should _File- >Save Page As..._ be considered the "elephant in the room" when
Firefox is discussed?

~~~
dredmorbius
EitR has more to do with known risks whose acknowledgement is inconvenient.
It's not a matter of DGAF, but rather, ignoring in the hopes that it will go
away, or the risk will fall on another.

[https://www.phrases.org.uk/meanings/elephant-in-the-
room.htm...](https://www.phrases.org.uk/meanings/elephant-in-the-room.html)

------
Firerouge
For Mac users, this can be easily installed and updated using brew.

~~~
fooker
I found brew's version of youtube-dl to be often out of date. Haven't tried
recently, this was last year.

~~~
computerfriend
It's one of my most frequently updated formulæ.

------
barking
I presume this is only for the occasional thing that people are afraid will
disappear from youtube or is there some other reason for downloading that I'm
missing?

~~~
gkya
Youtube wants me to concede too much JS execution on too many domains (I block
strictly), or else I can not skip the ads. It becomes a huge annoyance when
I'm watching my favourite TV show that's also uploaded to YT and I have the
same idiotic Grammarly ad in my face every 10 minutes. But I can easily run
mpv <url> and watch, without looking at ads that are completely uninteresting
and persistent enough to feel harassing to me (youtube is showing me grammarly
ads since months, almost nothing else; so much that I loathe grammarly now).

Also when watching a video, with mpv (which uses youtube-dl for youtube videos
etc., I can pin a small video window on top of all other windows and continue
doing other stuff on my laptop.

~~~
Lev1a
I assume from your comment you only use a script blocker (like uMatrix,
Noscript, ...?) but not an actual ad blocker (I'd recommend uBlock Origin).

That would make your grammarly problem go away pretty fast.

~~~
gkya
I use Ublock origin w/ dynamic blocking (i.e. I decide for each site the
domains they can load stuff from), and only enable a handful domains to load
only first party JS (or some trustable 3rd party for a couple web sites), so I
don't think I need the ad blocker too. Also, browsing YT from the website and
watcing from mpv is way more convenient and less resource intensive. But
thanks for the info!

------
lettergram
Ive been watching this repo for over a while. It's very active and I highly
recommend trying it out. It's a pretty nifty project with a lot or activity.

------
Cofike
Love this library, I've used it with the python wrapper that makes it pretty
easy to get going.

------
rolodato
"From YouTube.com" is a massive understatement. youtube-dl can download from
pretty much any video site, including porn sites:
[https://github.com/rg3/youtube-
dl/issues?q=is%3Aopen+is%3Ais...](https://github.com/rg3/youtube-
dl/issues?q=is%3Aopen+is%3Aissue+label%3Ansfw)

~~~
toomuchtodo
Adding additional extractors is also trivial.

~~~
voltagex_
Have you got an example? I couldn't work out how to do it last time, but it's
easier for me to get an Australian geoblocked site going than it is to submit
a bug report and wait for someone to use a proxy.

~~~
bschwindHN
All their extractors can be found here:

[https://github.com/rg3/youtube-
dl/tree/master/youtube_dl/ext...](https://github.com/rg3/youtube-
dl/tree/master/youtube_dl/extractor)

------
tzahola
I used to use it frequently, but nowadays I just replace “youtube.com” with
“hooktube.com” in the URL.

~~~
JackCh
If you have ffmpeg, youtube-dl will let you mix and match any audio and video
stream you choose, giving you a lot of options that hooktube simply doesn't.
For instance you can combine a very small low quality video stream with a high
quality audio stream, if you know you're mostly just going to be listening to
the video.

------
pwaai
I just hit download and I can watch any movie on Premium, but i appreciate
this tool as well

~~~
dannyw
Those downloads get removed if the uploader deletes the video.

~~~
swebs
How does that work? Does it require giving Youtube access to your file system?

~~~
dannyw
Downloads only work within the app. Videos are DRM’d and you must connect to
the internet at least once every 30 days to watch.

