Web application for downloading youtube audio with Python libraries
Idea: Design a simple web application using Flask framework as main architecture solution. The realization includes next stages: (1)…
Web application for downloading youtube audio with Python libraries

Photo from pexels.com by cottonbro studio
Idea: Design a simple web application using Flask framework as main architecture solution. The realization includes next stages: (1) execution asynchronous tasks by using Celery and Redis; (2) downloading data from youtube.com by using Youtube-dl; (3) uploading audio to a cloud storage.
The simplicity can be explained as non-scaling solution, just for personal using app which you can be deployed on any environment. I can get the audio from any video in youtube for further listening on any devices which can work with cloud storage.
Prerequisites
Please install below components as per your OS:
- Docker.io
- Python ≥ 3.8
- Provisioning : RAM from 4 Gb, CPU from 2, HDD from 20 Gb.
Architecture
The use case is to build a web app with simple way for authentification, which allow to use page with form for filling all necessary parameters as Frontend side. The Backend side will implement the logic with minimum complexity for starting in async mode the core pipeline of main idea this app.
As source of media content I use the famous hosting like youtube.com. As target storage I use the one of the cloud storages such as Mega (https://mega.nz/about) which can provide the optimal volume of storage as free and can be connected through Python.

Architecture
All project assembled on GitHub repository, just feel free to clone it: https://github.com/BermanDS/youtube_downloader.git
Front End side
In that app I use just one HTML page with necessary form which I can be submitted as POST request for further parsing as parameters on Back end side.

Main page
The authorization implemented as token which you can transmit through GET parameter in URL link of your browser.
http://<host>:<port>/?token=<access_token>
At the next stages I don’t need to provide the access token, because the app will generate the internal token and store it as cookie. After authorization I can use form for filling my parameters.

The page with form
I need to fill required input info such as link(s) for video from youtube (at least one link, maximum three links), define kind of source such as “Youtube” (I suppose this app can be extended for using some other source). And define the path in my cloud storage related with root directory.
Additionally, I can choose bitrate of my output audio file and boolean feature of making transliteration from cyrillic to english (this feature can be extended for making possible transliterations from other languages as TODO).
If I need to logout from the app — just choose the item “Delete my cookies”. I tried to design very simple logic.
Back End side
On backend I realized the initialization of Flask App in relation with Celery as main context for async tasks. The Redis instance I use as broker for Celery and as broker for exchanging the internal states of workflows. The Redis I use as service in the same instance of the app in terms of simplicity.
The async tasks can be just one kind — with next stages: (1) downloading data; (2) scraping the Mp3 format according to settings in yaml config file; (3) renaming the file for compatible name; (4) uploading on storage.
Usually, the duration can be in range of 3–5 min in case of short songs (~3–4 min) or up to 30–50 min — if there are a continuous videos (~60–90 min).
[embed]
The core of parsing data by using youtube-dl:
[embed]
For uploading data to cloud I use the library https://github.com/odwyersoftware/mega.py for the Mega.co.nz API. I’m using this provider for many years for my personal projects and by now I have good user experience without negative consequences. I designed the custom object in Python as connector for their API and I tried to implement all necessary branches of processing behavior.
Deploying app
First of all, please paste in .env all required variables: MEGACLOUDUSER, MEGACLOUDPASSW (cloud credentials), REDIS__HOST (in this example it should be localhost — 127.0.0.1), APIBOT_TOKEN (main access token for authorization app), API_PORT, FLOWER_PORT (for monitoring async tasks), timezone (choice of timezone), LOCAL_DATA (directory for storing temporary data), LOGS_PATH (directory for logs).
My Supervisor configuration file launches the necessary processes after starting instance.
[embed]
After configuring all settings, just try next command:
_node: ~/work/youtube_downloader$ docker-compose up --build -d
If you can visit main page — you can use web app. Cool!
Conclusion
This is web app which can provide useful feature for collecting favorite content, structure it and use it on other devices. I like Python for these features))
메타데이터
- post_id
- 8cd8be3d02fb
- slug
- web-application-for-downloading-youtube-audio-with-python-libraries-8cd8be3d02fb
- url
- https://medium.com/@aaron.cpsh/web-application-for-downloading-youtube-audio-with-python-libraries-8cd8be3d02fb
- canonical_url
- https://medium.com/@aaron.cpsh/web-application-for-downloading-youtube-audio-with-python-libraries-8cd8be3d02fb
- author_url
- https://medium.com/@aaron.cpsh
- status
- ok
- fetched_at
- 2026-06-22 05:50:54