Hacker News new | past | comments | ask | show | jobs | submit login
Youtube-dl: Command-line program to download videos (github.com/rg3)
581 points by axiomdata316 on July 4, 2018 | hide | past | favorite | 248 comments

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.

12 years ago i built google video downloader as a way to help me learn C#. it took about a month after the release for google to defeat my basic scraping. I did a few iterations to circumvent their changes, and then they changed tact, and erased the project from google. they only let it back into the search results after i stopped maintaining it.


Google Do Evil I guess.

Last time I talked to Youtubers about this, they acknowledged that there are several important things that youtube-dl can do which the official YT API cannot; the biggest feature is that youtube-dl can archive Creative Commons-licensed footage.

Youtube does occasionally attempt to break CLI tools. get-flash-videos has been beaten down hard by JS-powered authentication, but youtube-dl emulates the JS player. Ads are still broken in youtube-dl, although strangely nobody seems to want to fix them!

I think command line utilities will usually be the last to receive active counter measures as they are generally considered to be used only by geeks which constitute a negligible percent of consumers.

Youtube-dl has lots of GUI frontends and is embedded in easy to use Android apps.

I don't use the Play Store but a friend recently asked me for a youtube-dl frontend for Android (using other words), care to name some?

Not the GP, but NewPipe is the one I'm familiar with. It's available on F-Droid.

I use NewPipe, but my friend does not sideload apps or use F-Droid, that's why I'm asking for Play Store options.

It's unlikely that you will find a long standing play store app with youtube-dl built in.

Well, should we be listing the related Apps here?

> the first rule of youtube-dl is not to talk about youtube-dl

There are ~40 hits for "youtube-dl" in Play Store: https://play.google.com/store/search?q=youtube-dl&c=apps

But I agree that people might have mixed feelings on pointing to the ones that work better.

I made another search, through DuckDuckGo, and got a hit that's not among those ~40 and looks good: https://play.google.com/store/apps/details?id=com.aviddapp.o...

Am I hurting them by linking, or any of you for adding feedback?

Ark tube is a good front-end for youtube-dl https://forum.xda-developers.com/general/paid-software/app-a...

Problem is, just because something is "in the Play Store" doesn't mean it is harmless. It could, for example, contain trackers. So, yes, we should discuss and link them.

The Play Store doesn't allow YouTube downloaders, so I doubt you'll find any good ones there. The moment one gets popular, it's taken down.

It's a bit hacky and out of reach to most casual users, but you can get YouTube-DL to work with Termux.

I have it set so that whenever I use the Termux share intent from another app, it use the shared URL and calls YouTube-DL with some parameters I want.


    youtube-dl $url

    # Default Output Directory and Pattern
    -o /data/data/com.termux/files/home/storage/downloads/%(extractor_key)s/%(uploader)s/%(title)s-%(id)s.%(ext)s

This is the classic cat-and-mouse game. We are pretty good at it by now.

Are we?

When was the last widely available iOS jailbreak available? The last Xbox One one? PS4? Android bootloaders?

Youtube is a different beast, of course, but that's why the powers that be pushed EME down our throat (and maybe it doesn't yet but it WILL require protected media paths and stuff in the future). Once EME is reasonably well done and prevalent -- we'll have to download youtube through the analog hole.

I don't know. Netflix is doing a pretty good job shutting down VPN proxying.

Yes, I know there are some providers that still work... Shhhh!

However, it's a lot easier for Netflix to blacklist an IP (or an entire IP range) than it is for a provider to setup a whole new proxy - likely connected via a residential ISP.

But they're not doing a good job in blacklisting debit card providers (providers that let you generate your own unique debit card number and start a free trial on this new card, resulting in using the service for free) or banning shared accounts (i.e. 4 people meet on the internet only for the purposes of buying one account).

VPN connections are relatively easier to block.

Not everyone has fast enough bandwidth to watch live videos.

Many people rely on downloaders to actually watch the video.

And by not everyone you can very well mean Youtube itself. I'm in Hungary, sometimes I watch gameplay videos that are only enjoyable in at least 720p and Youtube can't keep up with the bandwidth. I have a 1 gbit connection. And Youtube won't buffer the whole video if you pause it. youtube-dl is really a must in this situation.

I'm not familiar with the situation in hungary but isn't it more likely that your ISP is throttling or otherwise artificially limiting the connection to Youtube, Netflix and other services with bandwith-heavy content.

Well, they don't throttle torrent in any noticeable way (torrenting with 10-20 MB/s or even more is not uncommon). And torrenting is pretty active in Hungary. They also provide ipv6 addresses too, I really can't say anything bad about my ISP. But it could very well be them who do the throttling to Youtube, I can't any way verify that.

Try running it through a VPN. I recommend NordVPN these days. Had good luck with Torguard in the past as well.

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

FWIW, youtube-dl can download from a ton of sites...


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.

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

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.

Do you know where to find this or if this is definitely true? I tried looking around before and YouTube-dl didn’t have any ad downloading ability. I just tried looking now and at first glance it doesn’t look like it does. Nothing in the changelog for past year either.

It can download ads. It is a command line option.

In my case a vast majority of use is just to be able to pipe the original stream to mpv/vlc in order to reduce the cpu usage. In the past there was a clear benefit, maybe less so these days.

Could not agree more, especially as it’s a tool I use multiple times a day and I don’t think it’s ever failed me.

But it's just like WGET[1], and last time I checked, WGET is not a crime. I even have a funny sticker on my laptop that says that.

[1]: https://en.wikipedia.org/wiki/Wget

That would be sad, but I'll ditch Youtube for good if they'll introduce this garbage.

YouTube has the network effect just like every other big provider. You can’t ditch it unless the content you want to see has decided to move elsewhere.

Important and desirable media is almost always available from more than one source. If not, then Sometimes, it's as simple as asking the producer to upload to your preferred streaming endpoint.

Your comment made me think of a web portal for uploading videos, so the content creator uploads once, and selects what content platforms he wishes to share it with.

The people behinnd the portal could have a sign-up page so that any platforms that wish to host a non-exclusive copy can sign up in order for uploaders to be able to select them as well. This could potentially cause the portal hosters (internet archive?) to suffer a lot of upload, but then there are no legal troubles whatsoever (assuming the uploader had the copyrights) in preserving or migrating content.

The big networks might refuse to sign up (to prevent such a portal and hence competing content networks from getting a foot in the door regarding network effect), or make it hard to have the single portal entity mediate the uploading to them in the name of the content owner, but in a sense it is not more cat-and-mouse game, but a differently placed one: at upload instead of download.

Tunecore does a similar thing for music: https://www.tunecore.com/sell-your-music-online

You upload your music, and they put it on the various services for a fee. Including YouTube if you select it.

This would be indeed nice. Which means, obviously, that they would be immediately buried in lawsuits. Sure, they would be in the right, which would make them happy after they're broke.

(Cynic, who me?)

What constitutes "important and desirable media" is extremely personal and subjective, and the producer will not always be available to respond to your request.

Here's an example of something that is very important and desirable to me but doesn't exist anywhere else on the internet.


I agree with you overall, but the album actually does exist here: https://yadi.sk/d/SMKn5Af43LitRc. At 320 kbps, it's a little higher quality than YouTube.

By the way, Diamond Harbour is fantastic. What other music do you love?

Well I’ll be. I’ve got a vinyl copy now so I’m in good standing quality wise.

You should check out the Growing Bin web store - there are some fascinating musical rarities and curios there. There’s some great stuff on Jamie Tiller’s label Music From Memory. His mixes (available on Soundcloud) are also excellent, as are those on the Red Light Radio Soundcloud. I could go on...

Do you not realize that you've linked to a YouTube video of a recording of a vinyl record?

In your case, the vinyl record is the other source. Not to mention the other one provided by the other respondent. And a vinyl record is a great source to have -- it will last a lot longer than any other digital link to a stream of a record, if cared for properly.

>Important and desirable media is almost always available from more than one source

We don't watch "important and desirable media" in YouTube (and most of us, not anywhere else, there). What we do watch is not really available elsewhere (e.g. certain vloggers, tutorial videos, etc).

You must have a pretty narrow definition of 'important and desirable', almost all of the content I consume on Youtube is not available elsewhere afaik.

I don't think pewdiepie uploads elsewhere, and his videos are important and desirable for 63 million people.

It is possible that this is true only insofar that they are readily available. If Youtube becomes difficult for his fans to access for some reason, they may find that they can live without his content.

That’s the same reasoning of ‘just ask people to use iMessage/Telegram/Signal’. Most people, whether they are producers or persons you want to talk with don’t want to deal with learning an extra platform. Don’t get me wrong, I love Telegram and YouTube not being the only player would make for a healthier market, but it just doesn’t work that way. I mean, how many people do you know that are not on WhatsApp? Its so ubiquitous market penetration is something like 90%+..

I don't know, because I am not on Whatsapp and it's never come up with any of my friends. Nobody thinks any less of me for this, and nobody has ever asked me to get Whatsapp. Perhaps my friends are nicer than others' here, but what ever happened to respecting people's choices?

We live on the internet, a place of infinite possibilities and uses. To suggest that it is natural, convenient, and appropriate to pigeonhole our services in this manner is thoroughly antithetical.

This is not feasible for the majority of users.

I follow ~360 YT channels, I desire them very much and they are not uploading it anywhere else.

Why don't you try asking them?

Nonetheless, I am sure that you could live without any of the content hosted on those YouTube channels. The word "content" is a fair terminology in this context since if any media is so pigeonholed as to demand being streamed and served from YouTube, it must not be that artistic, thoughtful, or useful to most viewers. YouTube doesn't optimize for utility, art, usefulness, tact, expression, or value. It optimizes for addiction.

Or you know, reduce your perceived need for said content.

More often that not, that's the choice I make. You make it too hard or intrusive for me to see your content and I stop taking part.

And it's funny, a lot of the time when I do this, I'll see a news article pop up a week/month/year later that said content provider is adjusting its policies, seemingly indicating that others are independently making the same choices.

This has happened several times, most notably when I cancelled our Dish junk right before the big "cord cutter" boom. Stop participating if you do not like it. You will survive.

The only way to make the content move elsewhere is to have enough people move elsewhere so that the content needs to move to meet an audience.

And this is why we should encourage content creators to cross publish their videos on peertube/steemit etc.

Or we should regulate them, maybe Trump would consider it. It certainly would not cause any sort of economic harm to regulate companies that sit on cash reserves in the hundred billions.


YouTube while it may contain a lot of video of content is really actually pretty poor product IMO. Lots of buffering, lots of ads, the apps have terrible UX as does the website and now that google is becoming less and less trustful (some would say always were but just becoming more evil with more data) I welcome video content hosted elsewhere. I really like Vimeo not just for the performance and video quality but I also find the interface quite good to use, it would probably need some adjustments if it were to take on the amount of content YouTube has.

I am actually surprised that many people didn't know about this handy tool

While I agree with you in principle (and have used a very similar setup for many years), I don't think HN is pro-DRM/IP enough to worry.

At some point YouTube is going to require an EME module to play even "free" videos.

...which will be cracked within days if not hours.

> which will be cracked within days if not hours.

Netflix requires an EME module since quite some time, and I'm not aware of any successful cracks.

All Netflix-exclusive shows are available up to 4K on torrent networks:




What’s left to steal?

Meanwhile the majority of Netflix customers is limited to 720p video like it’s 2001. [1]

[1] https://help.netflix.com/en/node/55763

> Google Chrome up to 720p

  Internet Explorer up to 1080p

  Microsoft Edge up to 4K*

  Mozilla Firefox up to 720p

  Opera up to 720p

  Windows 8 app up to 1080p

  Windows 10 app up to 4K*
(from your link). And people wonder why I still use torrents...

Depends what we mean by 'crack'.

A few years ago I was surprised to see that Netflix in Chrome on Linux didn't prevent screen-capture. If I recall correctly, On Windows, it won't let you screenshot Netflix - you get a black box instead.

Failing that, it's possible to record high-quality analogue output from, say, a Playstation 3. Failing that, it's always possible to point a camera at a screen.

Piracy of video isn't something that technologies like EME can hope to eliminate entirely, they can only raise the bar. For Netflix, that's acceptable. They compete with BitTorrent piracy and win on convenience.

Only Windows with Edge can play 4k. Chrome is 720p.

Have you tried Netflix on Edge? Maybe it's just anecdotal, but I've tried multiple i7 (3xxx, 5xxx, 7xxx and 8xxx series) and Ryzen 1700/1700x systems (GPU: NVIDIA 960M, 970, 1050, 2 different 1070 TIs) and ALL of them lag horribly while using Edge. Loading Netflix is slow. Selecting a profile takes several seconds. The entire browser locks up. I generally find a show using Firefox, then open Edge and search manually to get my 1080p playback. I'm wondering if it's just a bug but it's been like this on 4 different computers so far. Netflix the App itself is also incredibly laggy on Windows 10, not sure if the issues are somehow related to one another. Am I the only one who has this?

>Have you tried Netflix on Edge?

I don't have Netflix

Fair point.

Apparently it's possible to trick Netflix into 1080P on Chrome, in at least some cases - https://www.ghacks.net/2018/02/12/watch-netflix-in-1080p-on-...

Well Netflix's content is pirated just as much as any other content, so I guess it was cracked in some way?

You can strip HDCP from HDMI 2.2 [0] and then just capture that stream. Very easy to do. Anything that can be seen on your screen can be captured and shared.

0. https://www.amazon.com/HDMI-Splitter-Supports-Pass-through-D...

Where does it say "strip"?

>-Support HDR & HDCP 2.2 Pass-through

Which is not stripping away anything.

Like flashlight apps containing hidden tethering proxies[1], these products would quickly be taken down if they advertised their real functionality.

Those who remember the old analogue "video stabilisers" used for stripping Macrovision copy protection signals will find this similar.

[1] https://www.wired.com/2010/07/apple-approves-pulls-flashligh...

It is passthrough, but it just so happens that the hdcp protection doesn't quite make it through on many of these devices.

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:


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.

Only thing about embedding is that videos can be removed at any time for any reason (or no reason at all). Plus having the downloaded videos make it easy to load up on an iPad or similar device for offline viewing on long trips where internet access may not be guaranteed.

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

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.

don't you still get recommended or autoplay started videos at the end of an embedded video? or is there a way to control that as well?

You can turn that off.

Oh, nice one!

Just for posterity and fun, I'll post this quick and hacky lua script I wrote to do the job for me some time ago.


It requires a few lua modules and CLI tools, for example https://github.com/sharkdp/fd - like all the lua scripts I write for my own use.

Also, now that I was going to post it, I went through my system log and noticed it actually has problems if the youtube ID includes a dash (-), because I didn't escape the ID in the ytdl() call at the bottom. I'll leave that as an exercise for the reader.

And, of course, I removed the controversial feeds in the list before posting.

Anyway, it works fine for me - hopefully it can inspire others :-)

Elsagate is the creepiest thing I've seen on youtube in awhile.

youtube might not even be the worst offender these days


disclaimer: i did not watch the video, but guessed from reading the reddit comments

This is really useful, thanks. Got a nearly three-year old and I've been terrified of the weird stuff on youtube.

>Since letting kids alone on youtube, is clusterf* of a nightmare,

Could you have caked on more hyperbole? Yes, let's just let kids search the Internet and see what they come up with.

I wouldn't call it hyperbole at all once you learn about Elsagate.

Doesn't need to be elsagate level, stuff get's questionable to abusive (think unregulated child labor and unnessary emotional stress) really fast. It's worrysome on both producer and viewer side at pre-teen ages especially.

Parenting against a hyper-engineered viewer retention (recommendation is an euphemism at this point) engine is a lost cause to begin with. Tried supervised youtube with my 3 year old for a while and it's always going places you would never expect, and not in a good way.

Even for quality content, just look what wildbrain or DHX Media?, did in terms of ad-count, to "Yo Gabba Gabba" recently:


I count up 20 partly animated ad overlays plus a preroll in just 20m, who is willing to monitor that as a parent?

The core of the problem I have with the whole thing, is that YouTube prays on the weakest of the weakest, not even me. It's children of parents that simply can't afford daycare and video subscription services, that I worry about the most.

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


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

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...)

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

mpv (mpv.io) also has support for using it to stream videos. (play from the internet, rather than downloading)

https://addons.mozilla.org/en-US/firefox/addon/open-with/ is available for firefox and chrome, and lets you open URLs from the context menu. Massive time saver, as you can just right click on a link to a video, and it'll start playing in a separate media player.

I keep expecting the maintainers to change the name some day... I mainly use it to archive content from Arte. I'm usually not in the +7 days cycle their website has.

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.

I had this moment when I decided to throw a crunchyroll url at it on a whim and it worked flawlessly.

Even works with twitch which I find really handy

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.

Significantly more, actually. It can download videos from just about any website, and yes, including and especially NSFW ones.

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).

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.

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.

--no-osc will disable any OSD in mpv. osc=no in mpv.conf

Doesn't work - I still get the OSD while seeking.

How about osd-level=0 with no-osc? In my (quick) testing this works.

mpv is using youtube-dl itself.

Which is great with twitch. Instant benefits : no chat, video decoding outside browser. On some laptops it makes a big difference.

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.

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...

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...

--user-agent "" --no-mtime

It obviously seemed like a good idea in 1991 but in retrospect the User-Agent header was probably a bad idea. TBL never anticipated it would be abused by servers for this, and for browser fingerprinting...

`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. '

Just install mpv, dude.

It works right out of the box, if youtube-dl is in your PATH.

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.

I set this up recently (the 'Play with MPV' method) after noting that viewing YouTube in the browser had a far greater CPU usage than watching the same in mpv.

I've also given gtk-youtube-viewer a spin but it doesn't do "new videos of your subscriptions" (though it's command=line equivalent 'youtube-viewer -SV' does). Any recommendations out there for similar YouTube frontends?

Also, at least in the UK, youtube-dl can access BBC iPlayer content without the login required on the web.

You can use a feed reader. I have Newsboat set up with a feed that shows all my YouTube subscriptions and a macro that opens the URL from the selected item in mpv.

I use a shell wrapper for mpv that takes the URL from the clipboard when no arguments are given:

  mpv() {
    if [ $# -eq 0 ]; then
      env mpv "$(xsel -b)"
      env mpv "$@"

What if you have "&& rm -rf /" in your clipboard and forget about it?

  $ mpv "&& rm -rf /"
  Playing: && rm -rf /
  [file] Cannot open file '&& rm -rf /': No such file or directory
  Failed to open && rm -rf /.

Since the cat's out of the bag. You can also just use a ClipIt action.

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.

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.

Depends what's being watched, but quite often with content like How-To's, conference talks, and lectures etc I take advantage of having speed control on a keypress ('[' or ']' = +/- 10%), left arrow to skip back a few seconds, backspace to drop to normal speed if I miss something, 's' for screenshot of an interesting graph or chart etc... At other times I might make more use of ',' and '.' to step back and forth one frame at a time or '4' to increase the brightness.

Using key presses to navigate through and control media like this feels vaguely reminiscent of the first few times you really grok the power of editing a huge file with some well articulated vim or emacs commands. Also mpv seems less resource intensive whilst the browser has a lot of tabs open.

Videos are horribly choppy when I try to view them fullscreen in a browser. It's like playing a game without V-sync on. The same videos work flawlessly in MPV. Firefox in Ubuntu 18.04 with a Nvidia 750ti and proprietary drivers. YMMV.

`youtube-dl -g` will output the final URL it has resolved, which you can then pipe to any video player that supports streaming from an URL.

If you hold down shift, you can drag-and-drop youtube links into a running mpv instance to add those links to the current playlist.

> 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.

How did you do that? I would really like to have that setup also.

I used this extension:


mpv can easily be configured to open full screen on a specific screen.

So adding that button requires downloading and installing a file, and it has some references to openwith@darktrojan.net. I am not a web programmer but that doesn't seem right. The open with mpv browser extension, seems cleaner. https://addons.mozilla.org/en-US/firefox/addon/send-to-mpv-p...

Yeah, it didn't look good. The extension you posted downloads and installs the native client on its own, which is worse. However, you can't really do this any better, as the apps are sandboxed and not allowed to launch external programs.

I've audited the script for the extension I posted and it looks good, I've posted mine here: https://www.pastery.net/dyeamx/

yes. Seems you're right.

Thanks, I will take a look at that extension.

After reading the documentation for mpv I found the options --screen=<default|0-32> and --fs-screen=<all|current|0-32> these are used for selecting a specific screen.

Here's my config, now that I'm at the computer:


yup. you can a quick macro in qtebrowser as well. It gets rid of ads nicely too.

I was using Qutebrowser since some months because I had some problems with how Firefox causing data loss, but I had to go back to Firefox recently because Qutebrowser is too slow and memory-consuming w/ many tabs open, even if suspended (i.e. >= 10 or 15 tabs for me). Firefox 61 now consumes way less memory and no idle CPU at all thanks to a strict Ublock Origin policy (basically no JS or >=1Mb images if you're not a snowflake; I had similar blocking in Qutebrowser too). Is this something you experience too, or maybe caused by my setup?

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"

Me too. I have also set it to burn thumbnail:

alias mp3='youtube-dl -x --audio-format "mp3" --audio-quality 0 --embed-thumbnail $*'

In my ~/.bashrc, this works well for me. I did have to add --restrict-filenames after encountering some sites using really long titles that were problematic.

    mkdir /tmp/ytdl && cd /tmp/ytdl
    for URL in "$@" ; do youtube-dl -o '%(title)s.%(ext)s' "$URL" --restrict-filenames; done ;
    mv /tmp/ytdl/* ~/Desktop/
    rm -rf /tmp/ytdl

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

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"

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 soon. /shamelessplug

Youtube-dl can convert to mp3 and add cover-art from the Youtube thumbnail, not real cover-art, but in most cases that is fine:

$ youtube-dl --extract-audio --add-metadata --xattrs --embed-thumbnail --audio-quality 0 --audio-format mp3 URL

These two comments sum up the entire progression of my development career to date.

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

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.

> 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).

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.

Yep. I would rather and do pay for music. As said I use this predominantly for obscure stuff.

There are tons of anime music torrents out there, and even groups that let you xdcc download from IRC

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...

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.

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

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.

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.

> 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.

Geez, I'm pretty sure OP was talking about a mix playlist to play at home or for personal use, not for their professional DJ career aspirations.

I know they were. What’s your point?

> any youtube-dl format is as obvious to me as a file being ripped from source vinyl Since YT now encodes sound tracks in Opus 160 kbps, if upload was in any decent quality, it will be downloaded in it too.

Would you like a five minute lecture on frequency response and bandwidth of what you upload based on the dynamics compression, filtering, and other processing YouTube does to make videos sound good and all of which have nothing to do with a transport compression algorithm, but how said transport algorithms reduce bandwidth when double compressed because you’re probably not uploading 32-bit PCM to YouTube, and how none of that matters anyway because most people uploading to YouTube aren’t familiar with a spectrogram nor DC offset? (Seriously, one track I got via youtube-dl was the most offset I’d seen in my life. They either don’t fix it, or the fix goes horribly awry.)

I’d simply offer it but this thread thinks I’m an angry ranter so I’m making you not cower in fear out of respect.

i don't get the downvoting for this comment. i too used to carry 70+lbs of vinyl to gigs. CDJs became a thing around the same time napster/ftp trading/etc was popular. on a multi-thousand watt sound system, i agree that the sound was atrocious and quite obvious when a compressed format was burned to CD. that bothered me on multiple levels not just the sound quality, but there was a very large chance the music was downloaded from napster/ftp/etc and not paid for from a legitimate source.

from this thread and other similar to it, it is becoming clear that a vocal segment of HN readers are not concerned with copyright.

whoaa .. wasn't expecting all this. I just download songs to put in my android phone for running. Though I doubt your salty words. Mostly a bunch of drunk people in a crowded party want to dance and have fun. I am sorry that you had to spend a lot of money 'buying in'. But I think the point of a DJ is to play music to a crowd, get them to have fun and dance..

Thanks mr. Gatekeeper

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.

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

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

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!

Wow that’s really useful to know.

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

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].

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

Very useful! Did you hear about get_iPlayer too?

No, amazing!

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


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?

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

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)

Yeah, gotta add && sleep 3600 and go to bed.

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

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

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?

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

Right. That's essentially what I was trying to say.

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.

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.

If I published my diary or something personal in a newspaper, I would not have that right.

If you upload to youtube and make it public, then that's exactly what it is - public. You may have the right to pull it from Youtube one day, but that's the extent of it.

You should assume anything you let leave your own device is permanent. Anything else is a pretty big pipe dream

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:


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.


Youtube for Kids is another app which is kid-friendly


I’m particular to jdownloader. http://jdownloader.org Works on so many downloading services and also YouTube.

its much bigger, size wise. Youtube-dl also works perfectly from the command line.

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

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

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)?

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.

What was the video?

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?

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

MPC-BE has Youtube-dl integration aswell


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.


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).

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

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.

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.

Even better: it can use a batch file with URLs

I'm using a node version: 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.

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

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

Which is one of the aspects of why the DMCA is such bad law and DRM in general is a complete waste of time.

If you hand someone a stream of bits and a decryption key that turns it into a movie. They will figure out how to keep the decrypted movie around if they want or need to do that.

So then you get into a coevolutionary arms race where content licensing organizations feel they have the right to imposes draconian restrictions on peoples personal electronics. And mandated spyware is not really ethical either.

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?

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.


Hrmm... I'm not sure. At any point in the protocol is there a "copyright bit"? It only takes one bit, and it doesn't even have to be documented as serving that purpose. The StreamboxVCR case ended up cementing into law (because the Streambox people ran out of money and couldn't appear to answer the last appeal by RealNetworks) that disobeying one undocumented bit is all it takes to run afoul of section 1201 of the DMCA. I imagine there might be such a bit in the YouTube stream but I don't know. I'm also not sure how you could defend in court that creating the temporary copy in memory for purposes of playing a stream is given permission, but creating a more permanent one is not. Courts have held that transitory copies in memory are actual copies, and can constitute real infringement, but obviously YouTube gives implicit permission to users to the creation of that copy, and youtube-dl doesn't actually create any additional copies beside that, it just keeps it.

I think it's already been ruled (at least in Europe), that it isn't illegal to download from public streaming platform since "streaming" and "downloading" are the same thing.

I'll go check.

Edit: After checking, yes, of course as long as it's for personal use. It's against youtube TOS, but if the TOS is against the law...

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

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

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

My compromise is to install brew's version of python, then use pip to install youtube-dl

or macports

Or brew :P

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?

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.

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.

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!

It’s also the most reliable way to get hardware decoded YouTube on Linux.

Firefox and Chrome don’t support it last I checked, and I’m not sure if they even have GPU rendering on Linux by default.

Some players can hook into youtube-dl, so streaming is still possible.

I downloaded a bunch of videos for watching on the train when my commute was 3 hours and the 4G connection was absolute shit. Youtube-dl saved my sanity.

That is the main reason I download stuff from youtube. I am an academic and I've had more than one video I used in a class or wanted to use for research disappear. So now I download copies of all videos that I think I might use in a class or for research.

Not just for that, though that's a good reason.

I use this to download for offline viewing (such as when traveling), or to download and number an entire playlist at a time into a directory full of video files.

I use it because my internet at home is awful, and so I can either download it at home so I can watch it in one go later, or download a video when I am at a place with better internet.

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.

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

"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...

Adding additional extractors is also trivial.

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.

You can search through pull requests to see a few examples, but I wouldn't say it's that simple. Login in and authentication can be very different for each website.

All those NSFW labels. Maybe after all internet is made for pom.

Correct me if I'm wrong but I think advances in video streaming tech were pioneered by "cam girls" (porn).

Some even argue that HTTP won over Gopher because of Multimedia, more exactly image, support.

Title should be changed to reflect this fact.

Title has been truncated to reflect this fact.

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

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.

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

Those downloads get removed if the uploader deletes the video.

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

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.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact