cookies-from-browser option not working as expected
This one has me stumped, but I suspect it's not catt and is in yt-dlp. I am posting here first because running yt-dlp with --cookies-from-browser=firefox does work as intended.
I am running Linux and have used pipx catt to install catt. To test yt-dlp I used pipx yt-dlp and ensured I was running the local pipx version, and not the one on my system.
If I run catt cast -y 'cookies-from-browser=firefox' 'https://www.patreon.com/posts/...., I get:
ERROR: [Patreon] ....: You do not have access to this post.
Running ~/.local/bin/yt-dlp --cookies-from-browser=firefox 'https://www.patreon.com/posts/.... works correctly.
I added -y 'verbose=1' to the catt cli and yt-dlp acknowledges it got the 'cookies-from-browser=firefox' option,
[debug] params: {'verbose': '1', 'cookies-from-browser': 'firefox', 'compat_opts': set(), 'http_headers':....
But unlike when running yt-dlp directly, I do not see:
Extracting cookies from firefox
The versions of yt-dlp I tested above are identical:
[debug] yt-dlp version [email protected] from yt-dlp/yt-dlp [12b248ce6] (pip)
OK, so I think I have somewhat resolved this, but may still need an update in the documentation for catt. I'll leave this one open, but happy for it to be closed.
It looks like yt-dlp wants 'cookiesfrombrowser=firefox', without the dash (-).
I also spotted a bug in yt-dlp where in cookies.py; it passes the browser_specification string with a "*", and at least in my installation this dereferences to a list for each character in the string, which the function call to _parse_browser_specification is now seven parameters (for 'firefox'), causing an error. I'll open an issue over there if one hasn't been raised already.
I fixed it by removing the '*' and currently watching the video from the previous post.
It does look like something that might need fixing in catt, the parameter to the option passed through the api needs to be a tuple.
https://github.com/yt-dlp/yt-dlp/issues/10196#issuecomment-2171928333
Thanks for the investigation! Would you mind opening a PR?
I have stumbled upon this as well.
from yt_dlp.options import create_parser
YT_DLP_PARSER = create_parser()
def args_to_ytdlp_options(argument_list: List[str], defaults: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
return YT_DLP_PARSER.parse_args(argument_list, yt_dlp_optparse.Values(defaults))
Surely the option parser should take the incoming string, and parse it into the tuple itself.
Especially since --cookies-from-browser takes a specially formatted string that then needs transforming into the tuple:
'--cookies-from-browser', dest='cookiesfrombrowser', metavar='BROWSER[+KEYRING][:PROFILE][::CONTAINER]',
If I manually set the cookiesfrombrowser key in my code with a tuple, then it works correctly.
I think something along the lines of:
match = re.fullmatch('([^+:]+)(?:\+([^:]+))?(?::([^:]+))?(?:::([^:]+))?$', value)
dict[key] = (match[1], match[2], match[3], match[4])
would work in a callback in the optparse configuration.
Broken in v0.12.11:
$ catt -d 10.x.x.x cast https://www.youtube.com/watch?v=xxxxxxxxxx -y cookiesfrombrowser=firefox
ERROR: _parse_browser_specification() takes from 1 to 4 positional arguments but 7 were given
Error: Remote resource not found.
$ catt --version
catt v0.12.11, Zaniest Zapper.