Flask
application for youtube-dl
to download youtube videos. The docker image is based on python:alpine
.
This example uses the docker build
command to build the image and the docker run
command to create a container from that image. The container exposes port 5000 and volume /youtube-dl
.
docker build --tag youtube-dl-server .
docker run -d --name youtube-dl -p 5000:5000 -v ~/volumes/youtube-dl:/youtube-dl youtube-dl-server
This is an example service definition that could be added in docker-compose.yml
.
youtube-dl:
container_name: youtube-dl
build: ./services/youtube-dl/
volumes:
- ./volumes/youtube-dl:/youtube-dl
ports:
- 5000:5000
restart: unless-stopped
Optionally, you could make the download directory accessible with samba as shown in the example below.
samba:
image: dperson/samba:latest
environment:
- USER=<insert user>;<insert password>
- SHARE=youtube-dl;/mnt/youtube-dl;yes;no;yes;<insert user>;<insert user>
volumes:
- ./volumes/youtube-dl:/mnt/youtube-dl
ports:
- 137:137/udp
- 138:138/udp
- 139:139/tcp
- 445:445/tcp
restart: unless-stopped
Then run docker-compose up -d --build
.
If you have python 3 installed in your PATH you can simply run like this, providing optional environment variable overrides inline.
sudo YDL_SERVER_PORT=8123 python3 -u ./flask-server.py
Just navigate to http://{{host}}:5000/
and paste the video url or select .webloc files to the video's and click the Submit button.
Navigate to the Jobs tab to track download progress.
curl -X POST --data-urlencode "url={{url}}" http://{{host}}:5000/enqueue-url
fetch(`http://${host}:5000/enqueue-url`, {
method: "POST",
body: new URLSearchParams({
url: url,
format: "bestvideo"
}),
});
Add the following bookmarklet to your bookmark bar so you can conviently send the current page url to your youtube-dl-server instance.
javascript:!function(){fetch("http://${host}:5000/enqueue-url",{body:new URLSearchParams({url:window.location.href,format:"bestvideo"}),method:"POST"})}();