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
errors when Chrome/chromium-based browser is open in Windows
#7271
Comments
This comment was marked as duplicate.
This comment was marked as duplicate.
(edited to be useful) This issue affects Windows versions of Chrome and some other chromium-based browsers such as Edge. The workaround (at least for Chrome) is to launch For convenience, you can add it your desktop shortcut for Chrome. Right-click the shortcut, go into Properties, and change the executable path, e.g.: |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Also had a question regarding that. The file seems to be in use so it's being "locked" and for some reason I can't even read the file, but for some reason I could copy it? I'm on windows 11 so maybe it could be an OS thing but surely if you can copy a file, then there shouldn't be any issue with read access? |
This comment was marked as resolved.
This comment was marked as resolved.
There was also a report on discord a couple days ago about this same issue happening with Safari on macOS. |
I found the chromium commit-https://chromium.googlesource.com/chromium/src/+/03c1544d31014c04caace4145676c30586bd9612 |
As a temporary workaround, run --disable-features=LockProfileCookieDatabase Expect this flag to go away after a few more releases of Chrome. |
You can also modify the start menu shortcut (on my computer it's at If anyone's familiar with the location of windows start menu and taskbar shortcuts, and with the command prompt, it may be useful to create a batch file (or even better, a one-liner) to automatically do that |
Using the win32 copy instead of shutil copy doesn't work either. Might be possible to work around it with shadow copies. |
shadow copies work, though require admin. ... is it ok to prompt the user for admin to copy the cookies file somewhere else then use it after? |
No. User will need to start yt-dlp as admin in in that case. We can issue an appropriate error message, but do not elevate interactively |
Opened a PR to allow this to work at least when the user is admin via a shadow copy. (#7290) |
I don't have a solution but I have done some research that may be useful.
I tried moving the Cookies database and creating a symlink and hardlink to it for chrome to use but the shadow copy approach seems like a good way around the limitation on the yt-dlp side. I think admin will be required for any solution which makes many options available but most would be too invasive. The good news is that I don't think Linux will be affected because mandatory locking with fcntl is opt-in and disabled by default source (see Mandatory locking section). WSL should also be unaffected because |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
So if you read into it more, they actually disabled the Bing Wallpaper app's ability to check cookies this way as the fix. He explains it in full here: https://textslashplain.com/2022/05/26/losing-your-cookies/#:~:text=Culprit%3A%20SQLLite%20DB%20Load%20failure .. so in other words there still is no non-admin workaround. .. honestly if there was one based off what they did it would likely point to an OS security issue. The Chrome-like process locks the file for exclusive use. If you could obtain it while it had an exclusive lock, it would violate the expected OS behavior here. I still think shadowcopy is the best way around with a prompt to run as admin to use this feature on Windows. |
And I guess I spoke too soon-ish. This project: https://github.com/thewh1teagle/rookie came up with a way to do it without admin. It cheats a bit, it actually kills the process in chrome that holds the lock to the file.. thus releasing the lock... but hey chrome, just restarts it when needed and it works out fine. I've replicated it in a pure-python gist here: https://gist.github.com/csm10495/e89e660ffee0030e8ef410b793ad6a7e.. using that logic cookies can be fetched even while Chrome is running, without admin. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
bashonly's solution (adding the --disable-features=LockProfileCookieDatabase flag) used to work for me, but lately it has failed to. I'm right back at the "Errno 13" Permission denied" error that started this issue report. I am using Vivaldi, if that makes a difference. But again, bashonly's solution worked until just recently. |
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
That's kind of offensive tbh. I was just providing a possible solution. This is open source code, people make recommendations, code changes, etc. it's part of the culture. I'm not sure why my suggestion would not instill confidence. I'm offended by that remark. It makes me think I shouldn't share things that I think can help steer us towards a solution. I had been very excited to share that because it gives the possibility of fixing the issue for folks longer term. Honestly it's not a suggestion for someone who doesn't know python. It's a suggestion to other people at least somewhat familiar with parts of the yt-dlp source code. I'm not sure why you then say it shouldn't need to exist. None of us influenced the chromium behavior change here. We are where we are: trying to provide solutions. Anyways, you don't need |
That's a really handy extension, even better I will use my local cookies on my network raspberry yt-dlp server, thanks. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
I adapted the work of @csm10495 in to a yt-dlp plugin: https://github.com/seproDev/yt-dlp-ChromeCookieUnlock Seems to be working well for me. Use at your own risk. |
For some reason, not sure if related but the --disable-features=LockProfileCookieDatabase seemed to slow down and cause my chrome to hog more memory. Might be a no brainer, but worked better than the Chrome solution for me is to just get them from Firefox instead. --cookies-from-browser firefox |
@csm10495 I really appreciate all your help here and cookie3 repo with all the methods of getting cookies from chrome. I settled with rookiepy in a script and it worked great. Weird that it gaves the cookies as a list of dicts, which is incompatible with requests library. I simply converted it with: Thanks again for all your help! |
@csm10495 Would you be willing to Unlicense your script so we can merge it? |
I'm a big fan of yt-dlp, but sorry, I believe in attribution for my external open source code. The unlicence isn't really something I'm currently interested in. Thanks for considering it. |
In case it helps someone unfamiliar with plugins as I was, you can simply clone into the configuration directory like so (Windows example):
Now I'm just trying to find a way to get rid of the
|
@ofek seproDev/yt-dlp-ChromeCookieUnlock#1
then after PR is merged you can:
|
re: https://github.com/seproDev/yt-dlp-ChromeCookieUnlock/
Here is an example to help novice users quickly use the plug-in to solve this problem. You don't have to use anything from this example, you just need to store the corresponding files in the corresponding directory. |
I was shown following error: |
…ormation display added opening an instance with unblocked cookies for edge and chrome: --disable-features=LockProfileCookieDatabase yt-dlp/yt-dlp#7271
DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE
Checklist
Provide a description that is worded well enough to be understood
cannot extract cookies from chrome when the chrome browser is open
and after closing all the windows of chrome, it can run correctly
i have no idea what is going wrong
Provide verbose output that clearly demonstrates the problem
yt-dlp -vU <your command line>
)'verbose': True
toYoutubeDL
params instead[debug] Command-line config
) and insert it belowComplete Verbose Output
The text was updated successfully, but these errors were encountered: