ReVanced / restore-missing-youtube-watch-history

⌛ Script to import missing YouTube watch history
https://revanced.app
GNU General Public License v3.0
59 stars 6 forks source link

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

Closed DrumSlayers closed 6 months ago

DrumSlayers commented 6 months ago

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 (https://github.com/borisbabic/browser_cookie3/issues/180#issuecomment-1587691954), 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 commented 6 months ago

You should be able to access it if you close Chrome