mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 10:42:34 +01:00
[ytdl] fix --cookies-from-browser option parsing
This commit is contained in:
parent
540eaa5add
commit
f321272b7c
@ -249,6 +249,22 @@ def parse_command_line(module, argv):
|
||||
None if opts.match_filter is None
|
||||
else module.match_filter_func(opts.match_filter))
|
||||
|
||||
cookiesfrombrowser = getattr(opts, "cookiesfrombrowser", None)
|
||||
if cookiesfrombrowser:
|
||||
match = re.fullmatch(r"""(?x)
|
||||
(?P<name>[^+:]+)
|
||||
(?:\s*\+\s*(?P<keyring>[^:]+))?
|
||||
(?:\s*:\s*(?!:)(?P<profile>.+?))?
|
||||
(?:\s*::\s*(?P<container>.+))?
|
||||
""", cookiesfrombrowser)
|
||||
if match:
|
||||
browser, keyring, profile, container = match.groups()
|
||||
if keyring is not None:
|
||||
keyring = keyring.upper()
|
||||
cookiesfrombrowser = (browser.lower(), profile, keyring, container)
|
||||
else:
|
||||
cookiesfrombrowser = None
|
||||
|
||||
return {
|
||||
"usenetrc": opts.usenetrc,
|
||||
"netrc_location": getattr(opts, "netrc_location", None),
|
||||
@ -364,7 +380,7 @@ def parse_command_line(module, argv):
|
||||
"skip_playlist_after_errors": getattr(
|
||||
opts, "skip_playlist_after_errors", None),
|
||||
"cookiefile": opts.cookiefile,
|
||||
"cookiesfrombrowser": getattr(opts, "cookiesfrombrowser", None),
|
||||
"cookiesfrombrowser": cookiesfrombrowser,
|
||||
"nocheckcertificate": opts.no_check_certificate,
|
||||
"prefer_insecure": opts.prefer_insecure,
|
||||
"proxy": opts.proxy,
|
||||
|
@ -294,6 +294,20 @@ class Test_CommandlineArguments_YtDlp(Test_CommandlineArguments):
|
||||
self._(["--geo-bypass-ip-block", "198.51.100.14/24"],
|
||||
"geo_bypass", "198.51.100.14/24")
|
||||
|
||||
def test_cookiesfrombrowser(self):
|
||||
self._(["--cookies-from-browser", "firefox"],
|
||||
"cookiesfrombrowser", ("firefox", None, None, None))
|
||||
self._(["--cookies-from-browser", "firefox:profile"],
|
||||
"cookiesfrombrowser", ("firefox", "profile", None, None))
|
||||
self._(["--cookies-from-browser", "firefox+keyring"],
|
||||
"cookiesfrombrowser", ("firefox", None, "KEYRING", None))
|
||||
self._(["--cookies-from-browser", "firefox::container"],
|
||||
"cookiesfrombrowser", ("firefox", None, None, "container"))
|
||||
self._(["--cookies-from-browser",
|
||||
"firefox+keyring:profile::container"],
|
||||
"cookiesfrombrowser",
|
||||
("firefox", "profile", "KEYRING", "container"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(warnings="ignore")
|
||||
|
Loading…
Reference in New Issue
Block a user