Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cookies-from-browser option not working as expected #447

Open
mrmabs opened this issue Jun 16, 2024 · 6 comments
Open

cookies-from-browser option not working as expected #447

mrmabs opened this issue Jun 16, 2024 · 6 comments

Comments

@mrmabs
Copy link

mrmabs commented Jun 16, 2024

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 stable@2024.05.27 from yt-dlp/yt-dlp [12b248ce6] (pip)

@mrmabs
Copy link
Author

mrmabs commented Jun 16, 2024

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.

@mrmabs
Copy link
Author

mrmabs commented Jun 17, 2024

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.

yt-dlp/yt-dlp#10196 (comment)

@skorokithakis
Copy link
Owner

Thanks for the investigation! Would you mind opening a PR?

@jessicah
Copy link

jessicah commented Nov 27, 2024

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.

@jessicah
Copy link

jessicah commented Nov 27, 2024

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.

@corpix
Copy link

corpix commented Dec 25, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants