implement --cookies-from-browser (#1606)

most of the code is adapted from yt-dlp's implementation
and *should* work the same.
This commit is contained in:
Mike Fährmann
2022-05-07 23:03:48 +02:00
parent c4b9f7bab8
commit 6742f3bc1e
6 changed files with 1654 additions and 13 deletions

View File

@@ -311,10 +311,17 @@ class Extractor():
self.log.warning("cookies: %s", exc)
else:
self._cookiefile = cookiefile
elif isinstance(cookies, (list, tuple)):
from ..cookies import load_cookies
try:
load_cookies(self._cookiejar, cookies)
except Exception as exc:
self.log.warning("cookies: %s", exc)
else:
self.log.warning(
"expected 'dict' or 'str' value for 'cookies' option, "
"got '%s' (%s)", cookies.__class__.__name__, cookies)
"Expected 'dict', 'list', or 'str' value for 'cookies' "
"option, got '%s' (%s)",
cookies.__class__.__name__, cookies)
def _store_cookies(self):
"""Store the session's cookiejar in a cookies.txt file"""