REST-based API for downloading video or extracting audio from YouTube videos. This API is used by YTDL web application. Also ffmpeg is required in order to process video and audio files.
App requires Python 3.11 and poetry installed.
Run poetry
command below to install project dependencies (including ones needed for development).
$ poetry install
Before starting the application server you should create .env
file which will contain all necessary settings. Example configuration for Docker container:
DEBUG=True
ALLOW_ORIGINS="http://localhost,http://localhost:8080,http://localhost:8081,http://127.0.0.1,http://127.0.0.1:8080,http://127.0.0.1:8081"
MEDIA_PATH="/app/media"
After you're done with configuration simply execute script below:
$ ./scripts/run_devserver.sh
This will launch uvicorn
server with app on http://localhost:8080. You will also be able to check OpenAPI (Swagger) documentation on http://localhost:8080/docs.
$ docker compose up -d app
For local development using docker use watch
:
$ docker compose watch app
Before running tests for the first time create file .env.test
inside project directory with following content. Replace placeholders with real values:
Run pytest
with command below. --cov-report
flag will generate coverage report in HTML format.
$ pytest --cov-report html
- Set up machine for app container
$ fly launch --no-deploy
- Set environmental variables
$ fly secrets import
# your secrets are passed below
DEBUG=True
ALLOW_ORIGINS="http://localhost,http://localhost:8080,http://localhost:8081,http://127.0.0.1,http://127.0.0.1:8080,http://127.0.0.1:8081"
EOL
- Setup volume (optional)
Check the docs for more information. Note that volume name should be the same as specified in
fly.toml
file.
$ fly volumes create media -r <region code>
- Deploy app
$ fly deploy
Instructions based on this documentation page from Fly.io
- Run the command below and copy and copy the output:
$ fly tokens create deploy -x 999999h
- Go to repo's Settings -> Security section -> Secrets and variables -> Actions. Click New repository secret button and paste copied output key from previous step int Secret input.
This section describes potential issues that may occur when using API.
1. Issue: Video is downloaded and playing but audio is absent when opening video in QuickTime Player.
Solution: Open video in another player (VLC Player for example). Maybe QuickTime Player doesn't support audio codec used in video.