Barebones REST interface for getting youtube-dl/yt-dlp info from a longrunning process.
This is to improve performance over the cli implementation as we don't need to initialize the extractors again for every request.
Switched from youtube-dl
to yt-dlp
to get faster updates and some other improvements from yt-dlp not included in youtube-dl.
This example uses the docker run command to create the container to run the app. Binding to port 8080
docker run -d -p 8080:8080 --name youtube-dl rynoxx/youtube-dl-server
This is an example service definition that could be put in docker-compose.yml
. This service uses a VPN client container for its networking.
youtube-dl:
image: "rynoxx/youtube-dl-server"
network_mode: "service:vpn"
restart: always
If you have python ^3.6.0 installed in your PATH you can run it like this, providing optional environment variable overrides inline.
python3 -m uvicorn youtube_dl_server:app --port 8123
Data can be fetched by supplying the {{url}}
and {{format}}
of the requested video through the REST interface via curl, etc.
Format is the youtube-dl string for the -f option, i.e. bestvideo
or bestaudio[ext=webm+acodec=opus+asr=48000]/bestaudio
curl -X GET http://{{host}}:8080/info?url={{url}}&format={{format}}
fetch(`http://${host}:8080/info?url=${url}&format=${format}`);
The server uses starlette for the web framework and yt-dlp to handle the data fetching. The integration with yt-dlp makes use of their python api.
This docker image is based on python:3-alpine
and consequently alpine:3
.