From 547ea7146388c75020a6d266cfec012b2dee31d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 24 Jul 2019 21:19:11 +0200 Subject: [PATCH] [downloader.ytdl] add 'forward-cookies' option (#352) The "long" name is necessary because just calling it 'cookies' would clash with how the lookup for '--cookies' is implemented. --- docs/configuration.rst | 9 +++++++++ docs/gallery-dl.conf | 1 + gallery_dl/downloader/ytdl.py | 7 +++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index 0ceca9fb53..5d5a2af38f 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -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 ----------------------- =========== ===== diff --git a/docs/gallery-dl.conf b/docs/gallery-dl.conf index 2e448be4c0..a4a9ee02f2 100644 --- a/docs/gallery-dl.conf +++ b/docs/gallery-dl.conf @@ -164,6 +164,7 @@ "ytdl": { "format": null, + "forward-cookies": true, "mtime": true, "rate": null, "retries": 4, diff --git a/gallery_dl/downloader/ytdl.py b/gallery_dl/downloader/ytdl.py index da57935829..a2334873b6 100644 --- a/gallery_dl/downloader/ytdl.py +++ b/gallery_dl/downloader/ytdl.py @@ -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)