Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Permission Denied while accessing Chrome cookies, even with admin rights #2

Closed
DrumSlayers opened this issue Mar 5, 2024 · 1 comment

Comments

@DrumSlayers
Copy link

DrumSlayers commented Mar 5, 2024

While executing the script (Using Google Chrome browser) as an Administrator, i got the following:

PS C:\Users\USER\Documents\GIT\restore-missing-youtube-watch-history> python.exe .\main.py
Found 18024 videos to watch
Found 16033 videos to watch after de-duplication
Traceback (most recent call last):
  File "C:\Users\USER\Documents\GIT\restore-missing-youtube-watch-history\main.py", line 210, in <module>
    main()
  File "C:\Users\USER\Documents\GIT\restore-missing-youtube-watch-history\main.py", line 109, in main
    download_videos(kept, DONE_DIRECTORY, SLEEP_MIN,
  File "C:\Users\USER\Documents\GIT\restore-missing-youtube-watch-history\main.py", line 176, in download_videos
    with yt_dlp.YoutubeDL(opts) as ydl:
         ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\yt_dlp\YoutubeDL.py", line 687, in __init__
    self._request_director = self.build_request_director(_REQUEST_HANDLERS.values(), _RH_PREFERENCES)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\yt_dlp\YoutubeDL.py", line 4128, in build_request_director
    cookiejar=self.cookiejar,
              ^^^^^^^^^^^^^^
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\functools.py", line 1001, in __get__
    val = self.func(instance)
          ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\yt_dlp\YoutubeDL.py", line 4049, in cookiejar
    return load_cookies(
           ^^^^^^^^^^^^^
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\yt_dlp\cookies.py", line 91, in load_cookies
    extract_cookies_from_browser(browser_name, profile, YDLLogger(ydl), keyring=keyring, container=container))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\yt_dlp\cookies.py", line 112, in extract_cookies_from_browser
    return _extract_chrome_cookies(browser_name, profile, keyring, logger)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\yt_dlp\cookies.py", line 281, in _extract_chrome_cookies
    cursor = _open_database_copy(cookie_database_path, tmpdir)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\yt_dlp\cookies.py", line 1042, in _open_database_copy
    shutil.copy(database_path, database_copy_path)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\shutil.py", line 419, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\shutil.py", line 256, in copyfile
    with open(src, 'rb') as fsrc:
         ^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\USER\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Network\\Cookies'

It seem linked to the way Chrome locks the cookies files (borisbabic/browser_cookie3#180 (comment)), sadly, the command line option --disable-features=LockProfileCookieDatabase does not seem to fix my issue
Shadow Copy work around can maybe fix this issue as mentioned in the previous comment.
Does anyone have a clue ?

@oSumAtrIX
Copy link
Member

You should be able to access it if you close Chrome

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

No branches or pull requests

2 participants