Skip to content

Commit

Permalink
[downloader.ytdl] add 'forward-cookies' option (#352)
Browse files Browse the repository at this point in the history
The "long" name is necessary because just calling it 'cookies' would
clash with how the lookup for '--cookies' is implemented.
  • Loading branch information
mikf committed Jul 24, 2019
1 parent d9d44ad commit 547ea71
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
9 changes: 9 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,15 @@ Description Video `format selection
=========== =====


downloader.ytdl.forward-cookies
-------------------------------
=========== =====
Type ``bool``
Default ``true``
Description Forward cookies to youtube-dl.
=========== =====


downloader.ytdl.logging
-----------------------
=========== =====
Expand Down
1 change: 1 addition & 0 deletions docs/gallery-dl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
"ytdl":
{
"format": null,
"forward-cookies": true,
"mtime": true,
"rate": null,
"retries": 4,
Expand Down
7 changes: 5 additions & 2 deletions gallery_dl/downloader/ytdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ def __init__(self, extractor, output):

if self.config("logging", True):
options["logger"] = self.log
self.forward_cookies = self.config("forward-cookies", True)

self.ytdl = YoutubeDL(options)

def download(self, url, pathfmt):
for cookie in self.session.cookies:
self.ytdl.cookiejar.set_cookie(cookie)
if self.forward_cookies:
set_cookie = self.ytdl.cookiejar.set_cookie
for cookie in self.session.cookies:
set_cookie(cookie)

try:
info_dict = self.ytdl.extract_info(url[5:], download=False)
Expand Down

0 comments on commit 547ea71

Please sign in to comment.