Skip to content

Commit 27c43a8

Browse files
Add option to include cookiefile
This allows users to download age-restricted videos from the web interface.
1 parent f0fa865 commit 27c43a8

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@ docker run -d --net="host" --name youtube-dl -v /home/core/youtube-dl:/youtube-d
2020

2121
### Docker Compose
2222

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

2526
```yml
2627
youtube-dl:
2728
image: "kmb32123/youtube-dl-server"
2829
network_mode: "service:vpn"
30+
environment:
31+
- YDL_COOKIE_FILE=youtube.com_cookies.txt
2932
volumes:
3033
- /home/core/youtube-dl:/youtube-dl
3134
restart: always

youtube-dl-server.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,18 @@ def get_ydl_options(request_options):
113113
}
114114
)
115115

116-
return {
116+
options = {
117117
"format": ydl_vars["YDL_FORMAT"],
118118
"postprocessors": postprocessors,
119119
"outtmpl": ydl_vars["YDL_OUTPUT_TEMPLATE"],
120120
"download_archive": ydl_vars["YDL_ARCHIVE_FILE"],
121121
"updatetime": ydl_vars["YDL_UPDATE_TIME"] == "True",
122122
}
123123

124+
if ydl_vars["YDL_COOKIE_FILE"]:
125+
options["cookiefile"] = f"/youtube-dl/{ydl_vars['YDL_COOKIE_FILE']}"
126+
127+
return options
124128

125129
def download(url, request_options):
126130
with YoutubeDL(get_ydl_options(request_options)) as ydl:

0 commit comments

Comments
 (0)