[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.
This commit is contained in:
Mike Fährmann
2019-07-24 21:19:11 +02:00
parent d9d44ad953
commit 547ea71463
3 changed files with 15 additions and 2 deletions

View File

@@ -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 downloader.ytdl.logging
----------------------- -----------------------
=========== ===== =========== =====

View File

@@ -164,6 +164,7 @@
"ytdl": "ytdl":
{ {
"format": null, "format": null,
"forward-cookies": true,
"mtime": true, "mtime": true,
"rate": null, "rate": null,
"retries": 4, "retries": 4,

View File

@@ -34,12 +34,15 @@ class YoutubeDLDownloader(DownloaderBase):
if self.config("logging", True): if self.config("logging", True):
options["logger"] = self.log options["logger"] = self.log
self.forward_cookies = self.config("forward-cookies", True)
self.ytdl = YoutubeDL(options) self.ytdl = YoutubeDL(options)
def download(self, url, pathfmt): def download(self, url, pathfmt):
for cookie in self.session.cookies: if self.forward_cookies:
self.ytdl.cookiejar.set_cookie(cookie) set_cookie = self.ytdl.cookiejar.set_cookie
for cookie in self.session.cookies:
set_cookie(cookie)
try: try:
info_dict = self.ytdl.extract_info(url[5:], download=False) info_dict = self.ytdl.extract_info(url[5:], download=False)