|MP3 – Audio only
Download only (mp4) – Video and audio
AAC – Audio only
The text marking in red is the video ID, copy that piece out and paste it into the text box above.
I was bored one day, decided that I wanted to try something new with python, I decided that I wanted to try something that included the Web Server Gateway Interface also known as PEP 333
I settled on a program that encodes the youtube video format into an mp3, a simple task which later turns out to be quite the challenge.
FFmpeg is used as the conversion software, with an input pipe to the video, and the output being passed as an iterator for the web server. As a result, the user receives the file the as soon as the title for the video has been fetched from Youtube and it is ready to begin the download, once the users web browser starts pulling from the data, FFmpeg encodes the video stream received from Youtube and sends the resulting bytes straight to the user. Further resulting in no further data being stored on the server.
Just short of 200 lines of code, a very elegant application that usually performs as advertised.
Edit: Since youtube changed subtly, I’ve updated the fetcher to make it work again, furthermore, I’ve added the AAC encoding process to extract only music from the youtube video, AAC is technically the successor to MP3 and including it only makes sense as youtube encodes all its videos in AAC anyway.
I’ve also added a way to simply pass the download pipe to you, so you can get the mp4 file directly without the encoding stage provided by FFmpeg.