Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@ docker run -d --net="host" --name youtube-dl -v /home/core/youtube-dl:/youtube-d

### Docker Compose

This is an example service definition that could be put in `docker-compose.yml`. This service uses a VPN client container for its networking.
This is an example service definition that could be put in `docker-compose.yml`.
This service uses a VPN client container for its networking and has a cookie file for downloading age-restricted videos.

```yml
youtube-dl:
image: "kmb32123/youtube-dl-server"
network_mode: "service:vpn"
environment:
- YDL_COOKIE_FILE=youtube.com_cookies.txt
volumes:
- /home/core/youtube-dl:/youtube-dl
restart: always
Expand Down
6 changes: 5 additions & 1 deletion youtube-dl-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,18 @@ def get_ydl_options(request_options):
}
)

return {
options = {
"format": ydl_vars["YDL_FORMAT"],
"postprocessors": postprocessors,
"outtmpl": ydl_vars["YDL_OUTPUT_TEMPLATE"],
"download_archive": ydl_vars["YDL_ARCHIVE_FILE"],
"updatetime": ydl_vars["YDL_UPDATE_TIME"] == "True",
}

if ydl_vars["YDL_COOKIE_FILE"]:
options["cookiefile"] = f"/youtube-dl/{ydl_vars['YDL_COOKIE_FILE']}"

return options

def download(url, request_options):
with YoutubeDL(get_ydl_options(request_options)) as ydl:
Expand Down