Hacker News new | past | comments | ask | show | jobs | submit login
Building a YouTube MP3 Downloader with Exodus, FFmpeg, and AWS Lambda (intoli.com)
76 points by yarapavan on May 26, 2018 | hide | past | favorite | 29 comments



The bookmarklet is neat, but this seems over-worked compared to just

    youtube-dl --extract-audio --audio-format mp3 youtube.com/watch?v=00000000
[1] https://rg3.github.io/youtube-dl/


youtube-dl is awesome. I built a bash script around this use case, with some additional bits just for file management. I run "yety https://www.youtube.com/watch?v=thnXzUFJnfQ" and poof, the mp3 is dropboxed and available on all my devices.


Works on Android in Termux as well. You can use the clipboard plugin to enter url automatically and make the script a home screen icon.


Also clipgrab for the cmd allergic : https://clipgrab.org/


The actual youtube metadata extraction is performed by the awesome ytdl-core library https://www.npmjs.com/package/ytdl-core https://github.com/fent/node-ytdl-core

For local work, https://www.npmjs.com/package/ytdl is a CLI powered by the same module. There is also a python-based youtube-dl command https://rg3.github.io/youtube-dl/ that supports a ton of sites


Downloading YouTube files is ridiculously simple.

http://m.youtube.com/watch?v=XxXxXx&layout=mobile&ajax=1

There you have all stream files in a nice json format, which means opus and m4a for audio files.

I have a python project which is very quick to gather metadata, because I wanted to have a responsive YouTube app without using the browser. Had no time for it recently, though.


Thanks this is actually really useful. Never knew about it


or you could just generate direct link (@) in the browser and download m4a without any external programs.

@ "Download YouTube Videos as MP4" did that, but author removed that script from the internet (got google nastygram maybe?). Iv got a copy at https://github.com/raszpl/smplayer4YT


Why MP3? You could download AAC files from YouTube and don't bother with (necessarily lossy) conversion.


Maybe file size is an issue here?

Wouldn't ogg be a viable alternative too?


In their previous tutorial [1] their encoding settings show that they're targeting roughly 128 kb/s VBR, which is what YouTube AACs typically are, so that doesn't explain it. AAC (and Opus for that matter, which YouTube also often has) are superior formats, and lossy encoding should only happen once if possible- so this honestly makes me cringe a bit. In this case the (probably already lossy) source audio is lossily converted by YouTube and then again by ffmpeg/LAME with rather low bitrates at each step. A lot of quality is lost along the way.

Support for Opus is unfortunately still somewhat sparse, but AAC support is essentially universal on modern devicese. So I can't think of any reason to favor this approach over:

  youtube-dl -f bestaudio[ext=m4a] "$URL"
Even YouTube's 128 kb/s copies won't satisfy audiophiles.

[1] https://intoli.com/blog/transcoding-on-aws-lambda/


I can definitely understand you cringing about the re-encoding, but I just wanted to point out that the reason that we took this approach was simply to give a semi-plausible real-world example of how tools like aws-serverless-express [1] and Exodus [2] can be used to build useful APIs with AWS Lambda [3] and AWS Gateway [4]. These articles are primarily meant to be educational tutorials that people can use as a reference when writing and deploying their own APIs. The whole "converting to MP3" thing is just an easily understandable premise which lays out a clear goal for the tutorials to build upon.

[1] - https://github.com/awslabs/aws-serverless-express

[2] - https://github.com/intoli/exodus

[3] - https://aws.amazon.com/lambda/

[4] - https://aws.amazon.com/api-gateway/


Are there any tools that can take my subscription activity in YT and convert it into a podcast or RSS feed for me?

I’m just so tired of the algorithmic hooks to waste my time.

There are 5-6 channels I really enjoy but get tired of the effort needed to fend off the constant temptation tailored to my tastes.


https://podsync.net/ + Pocket Cast = <3 - doesn't work always unfortunately. For audio only I use https://huffduffer.com/ (well it's just adding single youtube videos to a customized podcast feed)


I'm pretty sure there are a few ways to do this: try inspecting the html of the page, you can find an xml url there. There used to be an 'export to rss' option buried somewhere in the sidebar, don't remember if that still works. On mobile so can't verify.

In regards to algorithmic hooks (nice shorthand, I'm borrowing that), there are various extensions available on the major browsers which block comments, the sidebar, videos loading in the player at the end of the video, etc.

I am finally quite happy with my defence kit, I should write about it somewhere. /r/nosurf has plenty of tips anyway.



Isn't using this sort of thing against YouTube tos?


Yes:

4C. You agree not to access Content through any technology or means other than the video playback pages of the Service itself, the Embeddable Player, or other explicitly authorized means YouTube may designate.

Source: https://www.youtube.com/static?gl=US&template=terms


How to define "the video playback pages"?

Is https://www.youtube.com/watch?v=[videoID] a "video playback page"?

Most "YouTube downloaders", just like any popular web browser, access the Content through these pages.

These pages contain the (escaped) URLs for the video in various formats.

Do the terms restrict the software, e.g. HTTP client, one can use to access to these URLs?

For example, "You agree not to access Content through any software other than Google Chrome, official Google mobile app, etc."

If a user prefers some other http client not approved by Google, is that a violation of the ToS?


I think they try to say "browser" without actually saying it. Who knows why.


The less specific, the more wiggle room for lawyers. You know perfectly well that they don't offer download buttons. I'm actually surprised that ytdl still works, so I guess it's not a serious problem actually and no need to obscure further than they already do. I as an amateur could not figure out how to get the files of yt or soundcloud. Reading scdl.py it looked simple enough but I'd need to register a developer api key. For ytdl I guess the source has become bloated and obscure by now so i wouldn't even try. Having a bunch of dependencies already seemed too cluttered.


As you can clearly use youtube without agreeing to those terms, I'm not sure how they would be enforceable


Maybe technically against the terms, but frankly, I think pretty much no-one will find it immoral if it's for your own use only and you're not distributing. Probably even explicitly legal in many jurisdictions that allow personal copies.


I guess it's country specific.


You can have it on the web with no issues until it gets popular as the music biz had one of these sites shut down.

If it’s just a github repo project not making any money then unless it gets crazy popular you should be fine.


Somewhat doubt it. I periodically download my favorites and liked videos. Hate it when videos get deleted and you don't even know the name of it.


YouTube horribly compresses their audio. I don't know why you would want to download mp3 from them. (music?)


I haven't had nearly that much trouble with more recent videos, which seem to have excellent sound reproduction. It very much depends on the original upload quality though. Some older videos (anything stuck on 240p or lower) are from a time before HD uploads were a thing, and surely used more aggressive compression.

Some uploaders are also simply unskilled; I'm mostly after video game soundtracks to listen to in my car, and especially for newer soundtracks you have to watch out for the uploaders trying to be "first" to gain the popularity, while sometimes using poor settings or a bad rip. There's nothing youtube can do to improve bad source audio.


they seem to use Opus with 160 kbit bitrate now, you can view the formats with youtube-dl -F. Bandcamp disallows using compressed source audio, i wish youtube would too.




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

Search: