Skip to content

Commit bc44e54

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

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
@@ -21,12 +21,15 @@ docker run -d --net="host" --name youtube-dl -v /home/core/youtube-dl:/youtube-d
2121

2222
### Docker Compose
2323

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

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

youtube-dl-server.py

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

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

122+
if ydl_vars["YDL_COOKIE_FILE"]:
123+
options["cookiefile"] = f"/youtube-dl/{ydl_vars['YDL_COOKIE_FILE']}"
124+
125+
return options
122126

123127
def download(url, request_options):
124128
with YoutubeDL(get_ydl_options(request_options)) as ydl:

0 commit comments

Comments
 (0)