Hacker News new | past | comments | ask | show | jobs | submit login
Open Source YouTube to MP3 Downloader (github.com/packjc)
125 points by packjc 14 days ago | hide | past | favorite | 81 comments



This seems to be a pretty straightforward GUI wrapper around https://github.com/Tyrrrz/YoutubeExplode and https://github.com/AydinAdn/MediaToolkit (see https://github.com/PackJC/YoutubeToMP3/blob/main/Form1.cs). Note the (admirable but non-OSI) terms of the former library if using any outputs from this software.

https://github.com/yt-dlp/yt-dlp is a well-maintained public domain alternative.


Interestingly, while the readme file mentions that crayon license, the license file itself is an unmodified MIT license. I wonder what the legal status of that is.


Note the final points of their reasoning:

> Q: If I make a derivative work based on your project (e.g. use your library), would I need to also include your terms of use in my own project?

> A: No, you don't have to do that. But I won't stop you if you want to.


Personally I just use a bookmarklet. Nothing to install, no website to visit. Just a local bookmark that shows the list of the video/audio file direct links.

https://github.com/minanagehsalalma/Youtube-Downloader-Bookm... (https://raw.githubusercontent.com/minanagehsalalma/Youtube-D...)


Does it work? Looking at the code, the regex it uses to find the urls seems to be:

    document.documentElement.innerHTML.match(/https?:\/\/[^\s/$.?#].[^\s]*videoplayback(?:\?|%3F)[^'"]+/g)
Tried this on two videos and it returned null both times.


Hmm, I'm not the creator of it, but yes it's been working for me. I would have thought a regex match would be pretty universal. I'm using a chromium based browser if that matters. Here's what I see when I use it: https://i.imgur.com/7eS132D.png

I tried in FireFox and Chromium on Linux, and get no matches in both browsers.

On Windows in Chrome, it indeed works.


Tried it on 4 videos. Didn't work on any of them.


Doesn't work with DASH


Can't you still work around DASH by changing your user agent, claiming that you are running Safari? (It used to be the case, but I haven't been in the streaming industry for years now so it may be obsolete)


What do you mean work around DASH?

DASH is the correct way to do this. The combined formats are legacy.


I mean “work around the fact it doesn't work with DASH”

Also, MPEG-DASH is the typical bloated design-by-committee standard, that have twenty ways to do the same thing and that makes it very hard to implement fully. It's PDF or SVG all over again.

(I uses to work on an implementation of a DASH web player that had much better coverage of the standard that the reference implementation back in 2015, and I can tell you it was a PITA)

HLS, while a bit primitive in a few annoying way (inclusing the fact that it mandated, at the time, the use of MPEG-2 TS), is at least a pragmatic standard that is reasonably implementable. (Even though HLS.js being really good compared to the DASH alternative makes it less likely that you'd need to do it by yourself).


Who needs MP3 in 2024? Retrocomputing does! So a really lightweight YouTube client capable of running on Windows 95 and/or 486-class machines producing MP3 output would make a really great sense. Can this? For everyone else there are AAC and OPUS.


I still use an iPod with Rockbox firmware as my everyday music player so I also still need mp3s :3


All iPods supported AAC and I imagine alternative firmware adds opus support, so you can just grab the original audio files from YouTube instead of converting them to MP3.


RockBox added OPUS support ages ago. Absolutely no need to perform lossy-to-lossy conversion when you can just grab and use the opus stream.


I installed Rockbox on iPod specifically to play Opus.

As long as there’s no mp3directcut https://mpesch3.de/) clone for Opus, the format lacks non-destructive fast editing. And while it can cut and edit raw aac, it works a lot better with mp3.

Non destructive editing is more important with the new formats, because they compress to smaller files and cause greater problems when you unpack and recompress them.

This is why mp3 still is a good format for 2024.


I always use MP3 since it's the most compatible. Doesn't make a difference for my hearing and I can use it anywhere. E.g. some car radios still have problems with other formats. Saying "who needs this" is very dismissive.


This is exactly what the poster you're answering to said.


No, the poster said it's good for retrocomputing, implying MP3 is outdated and no one should be using it normally.


Something in between. I actually thought of all the vintage tech (I'm a huge fan of) but car audios (which can be routinely used by non-geeks who generally use more or less modern tech for everything else) specifically didn't come into my mind.

for those of us comfy with the console:

    yt-dlp -x [YouTube or other url]


I have a command set up that basically does this:

    yt-dlp -i --format "bestaudio" -x --convert-thumbnail jpg --add-metadata --embed-metadata --embed-thumbnail --audio-format "best" -o "%(autonumber)02d %(title)s (%(upload_date>%Y-%m-%d)s) [%(id)s].%(ext)s" "https:// ... youtube URL ..."
This adds some tags and the thumbnail as cover file. It will save to whatever format the video itself has, usually .opus.


I think the "or other url" is important here. I didn't realise for a long time that I could put a reddit, Twitter or other URLs in there to download videos. You can find a complete list of supported sites here:

https://github.com/yt-dlp/yt-dlp/blob/master/supportedsites....


This is incredibly understated, and I’ve used it for various sites, but it should be noted that the alternative sites are some times out of date in yt-dlp.

I was hoping for a working download for NPR Music, but it failed me last week for Kiefer’s set on Tiny Desk. Couldn’t airplay or chromecast it (without doing the whole screen, with all the trade offs that entails), and HDMI did a weird thing on macOS where the playback was sped up in every major browser.

Had a resort to a Firefox extension to download the video and Plex it in order to use the TV. Of course, I didn’t see if they had a Roku or similar app, and was just impatient to wait for the YouTube upload. Sigh.


Oh yes. I know 'the others'. Works well.


Thanks, I didn't know about -x !

My usual is:

    yt-dlp -f 140 [url]
The -f 140 maps to the m4a format.


"-f m4a" also works and it's easier to remember.


Why not Opus.


There are many reasons, and as a user of Opus you are probably aware of the trade offs?


Haven't tracked trade offs recently, but I always use Opus when I save audio from Youtube since it's the best codec option there.


Wait what, what situation is opus worse than m4a? In my ABXing it's never lost to another lossy format.


My personal ecosystem is built around Apple-native formats.


I used to download with yt-dlp -x. But the sound is not good at all. I am not using a re-encoded format, so some yt videos may not have good sound quality.


imo a better alternative (did not test on other sites)

yt-dlp -f bestaudio <url>

it directly downloads the audio from youtube and does not require ffmpeg unlike the -x option. moreover, you can specify format (m4a or default webm) like so - replace "bestaudio" with "bestaudio[ext=<format>]"

this only falls short unless you explicitly need it in mp3 container.


my first reaction as well


YouTube presents audio in 2 forms under various bitrates and formats. AAC and OPUS. The Opus track @128kbps (even better than the sometimes available AAC @160kbps) is the highest quality and can be downloaded and played back by demuxing its WebM container to .opus or using a player which understands the WebM container.

This is what I prefer: Downloading original OPUS audio, demuxing to .opus, without reconversions using a bash oneliner. Highest Quality you can get from YouTube.

Appreciate the minimalistic UI, no frills. 170 MB for a YouTube MP3 Downloader seems a bit steep though.


> The Opus track @128kbps (even better than the sometimes available AAC @160kbps) is the highest quality…

Opus has an advantage over AAC-LC (not HE variants) at lower bitrates, but by 128 kbps Opus loses any efficiency advantage. AAC-LC is going to give you slightly better quality and far broader device compatibility.

https://hydrogenaud.io/index.php/topic,120166.0.html?PHPSESS...


I remux into ogg which still supports Opus but seemed to have wider player support. Great way to get tracks that don't seem to be available anywhere other than streaming.


Matroska Audio (.mka) is also a nice choice

https://en.wikipedia.org/wiki/Matroska


.opus _is_ an Ogg container, just with another filename.


Hmm, maybe whatever I was running into problems with just doesn't recognize the extension then. Sadly I don't remember what it was. Coulda been Plex, which wouldn't surprise me.


A lazy indexer could skip just based on filename, and a well implemented and current (although... Opus is a decade old now?) player would properly detect the Opus stream inside the .ogg file and decode properly.


Please don't reconvert good lossy format (opus) into much worser one (mp3). Lossy to lossy is always bad, especially so into worser one


I remember using online tools for this a decade ago. I'm surprised to see a new project for it. I wonder if there's a specific use-case the author needed it for or if this was just for fun.


Have you tried using online tools for this a _week_ ago?

Youtube has been pretty good at fighting the online tools, meanwhile, spammers have been pretty good at filling search results with non-tools full of ads.

I've found it difficult to do the occasional drive-by download, because none of the old tools (kickyouotube, etc) that I remember the name of work or exists, and googling for online services returns junk.


It's not online but stacher works quite well for my needs as a GUI wrapper for yt dlp.

https://stacher.io/


I love this kind of projects to learn how to program or to be introduced to a new programming language! Back in the day, when I was starting out in programming, I made one that was practically the same so that my parents could download songs from youtube without help (https://github.com/ErlantzCalvo/Alcachofa)


Several years ago, after finishing a coding bootcamp, I created this little web app that turns YouTube channels into an XML podcast feed. Might need to dust it off. https://github.com/plasticbugs/podcasty


Might be worth

a) highlighting that this extracts the audio track only (not everyone is 100% firm with their audio and video formats)

b) investigating whether one could, instead of downloading the highest video quality and then discarding it, download only the highest quality audio? (yt-dlp and cousins allow that.)


a) highlighting that this extracts the audio track only

I think it's pretty clear from the title that this is audio-only.


MP3 (audio-only) and MP4 (video) is a one-character difference. It's clear to the people that browse HackerNews, it is seldom clear to the layperson.


Laypeople have known what MP3s are since Napster was making headlines. Laypeople have mostly never heard of MP4.


Fewer remember modified mp4 with patched atom location to help play media while downloading off a CDN.

For most mobile users, using the more modern VP9 and HEVC essentially just burns battery life, and even modern GPU based desktop users usually see their card warm up on YT.

MP4 is far from perfect, but play/resume/skip-to location media mods for a web-server are common (js or html5 support is stable.) This saves a lot of grief setting up media servers, but most people now just use an online platform... rather than figure this stuff out.

I kind of miss the days a lazy layman coudn't post lame garbage video content.

Have a wonderful day =3


Nice. I’ve been building something similar in php. But then you have to have a web server to run it. And it uses yt-dlp, so you also often have to make sure that is up to date before you run it.


Or you can use for free https://mp3convert.org :) fast and easy.


I like yt-dlp, but I also see the value in something that looks and functions just like those websites people end up using anyways.


I do too, don’t get me wrong. yt-dlp has much more rich features and does a good bit more than this… however I’ve just been trying to challenge myself to make simple apps and I prefer GUIs over command.


yt-dlp_linux -f bestaudio --audio-quality 2 --embed-thumbnail --add-metadata --extract-audio --audio-format mp3 --no-mtime -o "%(title)s.%(ext)s" http://



Yeah except do yourself a favor and don't use mp3


Unless you're getting them for older hardware that only plays mp3 like my car stereo...


Why, objectively?


1) MP3 is dated. Modern codecs give better quality at smaller filesizes.

2) Any lossy re-encoding step degrades quality. You'll get the highest quality by saving the stream direct from the server and skipping the re-encode step. Just pass --extract-audio and skip all those other arguments.


Can you give examples of modern codecs which are a better choice?


In this case since YouTube will provide it in Opus, Opus is the best choice, so that you're not re-encoding from lossy to lossy.


Here is one test where they compare some formats. Opus came out on top, even though for MP3, they allowed for a significantly larger bitrate. The downside is that the test is old, encoders evolve all the time, although this is true to both Opus and MP3.

http://listening-test.coresv.net/results.htm

The other kind of comparison to consider is transparency - the ability of a lossy codec to be indistinguishable from the uncompressed source. MP3 is supposed to achieve this at 192 kbps, while OPUS can do it in 128.

https://wiki.hydrogenaud.io/index.php?title=Transparency

The best choice, at the end of the day, is wholly dependent of the context of the usage. If all of the source is in MP3 to begin with, it doesn't make sense to convert.


YouTube natively provides audio in AAC which is higher quality per bitrate than MP3.

AAC has very wide support. Only convert AAC to MP3 if your player really doesn't support AAC.


Gave it a try. Worked great!


Thank you for trying it out! Much appreciated :D


https://cobalt.tools is another great option. No downloads, no ads, supports several websites.


I use a telgram bot (controlled by node-red) that sends the URLs to a script [1] that uses a FIFO to download them one by one via yt-dlp. If the sender ID is from my mum, only the audio track is saved and made available to her via jellyfin. It has been working almost too well for 2 years. She has downloaded almost 1TB of audiobooks (all from youtube).

1: https://gist.github.com/entropie/d265e94136b9777cc6b3190189b...


I've been meaning to do something similar but slap HTTP in front of it and use a bookmarklet. It seems like this script is both the daemon and the submitter though? That's nice.


elegant. how is the written?


How do I run this on my phone where I listen to everything?


Alternatively you can install https://github.com/termux/termux-app and then use https://github.com/yt-dlp/yt-dlp in it


There are open source apps for that you can find on f-droid.


You install mobian and then… normally :D


NewPipe or xklb in Termux



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

Search: