Skip to content

Commit

Permalink
implement --cookies-from-browser (#1606)
Browse files Browse the repository at this point in the history
most of the code is adapted from yt-dlp's implementation
and *should* work the same.
  • Loading branch information
mikf committed May 7, 2022
1 parent c4b9f7b commit 6742f3b
Show file tree
Hide file tree
Showing 6 changed files with 1,654 additions and 13 deletions.
24 changes: 19 additions & 5 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -399,16 +399,19 @@ Description
extractor.*.cookies
-------------------
Type
|Path|_ or ``object``
|Path|_ or ``object`` or ``list``
Default
``null``
Description
Source to read additional cookies from. Either as
Source to read additional cookies from. This can be

* the |Path|_ to a Mozilla/Netscape format cookies.txt file or
* a JSON ``object`` specifying cookies as a name-to-value mapping
* The |Path|_ to a Mozilla/Netscape format cookies.txt file

Example:
.. code:: json
"~/.local/share/cookies-instagram-com.txt"
* An ``object`` specifying cookies as name-value pairs

.. code:: json
Expand All @@ -418,6 +421,17 @@ Description
"isAdult" : "1"
}
* A ``list`` with up to 3 entries specifying a browser profile.

* The first entry is the browser name
* The optional second entry is a profile name or an absolote path to a profile directory
* The optional third entry is the keyring to retrieve passwords for decrypting cookies from

.. code:: json
["firefox"]
["chromium", "Private", "kwallet"]
extractor.*.cookies-update
--------------------------
Expand Down
4 changes: 4 additions & 0 deletions gallery_dl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ def main():
config.set((), "skip", "abort:" + str(args.abort))
if args.terminate:
config.set((), "skip", "terminate:" + str(args.terminate))
if args.cookies_from_browser:
browser, _, profile = args.cookies_from_browser.partition(":")
browser, _, keyring = browser.partition("+")
config.set((), "cookies", (browser, profile, keyring))
for opts in args.options:
config.set(*opts)

Expand Down
Loading

0 comments on commit 6742f3b

Please sign in to comment.