Repository: yt-dlp
Issue: Cannot get cookies from Safari.
Labels: bug,good first issue,external issue,core:cookies

### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

- [X] I understand that I will be **blocked** if I *intentionally* remove or skip any mandatory\* field

### Checklist

- [X] I'm reporting a bug unrelated to a specific site
- [X] I've verified that I'm running yt-dlp version **2023.06.22** ([update instructions](https://github.com/yt-dlp/yt-dlp#update)) or later (specify commit)
- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details
- [X] I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/yt-dlp/yt-dlp/wiki/FAQ#video-url-contains-an-ampersand--and-im-getting-some-strange-output-1-2839-or-v-is-not-recognized-as-an-internal-or-external-command)
- [X] I've searched [known issues](https://github.com/yt-dlp/yt-dlp/issues/3766) and the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues **including closed ones**. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)

### Provide a description that is worded well enough to be understood

When downloading YouTube videos, I need to give cookies for it to be able to download age-gated content. This has worked in the past when using "cookies.txt" files, but I recently tried using the "--cookies-from-browser safari" tag. This doesn't work, however. It gives an error about `PermissionError: [Errno 1] Operation not permitted: '/Users/thecoderpro/Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies'`. 


### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [ ] If using API, add `'verbose': True` to `YoutubeDL` params instead
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

```shell
[debug] Command-line config: ['-f', 'bestvideo[ext=mp4][vcodec^=avc1]+bestaudio[ext=m4a][acodec^=mp4a]', 'https://www.youtube.com/playlist?list=PLDx09dtcE4z5qSZ1oDkKQ3qyBULjlME3O', '--cookies-from-browser', 'safari', '-vU']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2023.06.22 [812cdfa06] (pip)
[debug] Python 3.11.4 (CPython x86_64 64bit) - macOS-13.4-x86_64-i386-64bit (OpenSSL 1.1.1u  30 May 2023)
[debug] exe versions: ffmpeg 6.0 (setts), ffprobe 6.0, rtmpdump 2.4
[debug] Optional libraries: Cryptodome-3.18.0, brotli-1.0.9, certifi-2023.05.07, mutagen-1.46.0, sqlite3-2.6.0, websockets-11.0.3
[debug] Trying secondary cookie location
Traceback (most recent call last):
  File "/usr/local/bin/yt-dlp", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/Cellar/yt-dlp/2023.6.22/libexec/lib/python3.11/site-packages/yt_dlp/__init__.py", line 1008, in main
    _exit(*variadic(_real_main(argv)))
                    ^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/yt-dlp/2023.6.22/libexec/lib/python3.11/site-packages/yt_dlp/__init__.py", line 962, in _real_main
    with YoutubeDL(ydl_opts) as ydl:
         ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/yt-dlp/2023.6.22/libexec/lib/python3.11/site-packages/yt_dlp/YoutubeDL.py", line 674, in __init__
    self.print_debug_header()
  File "/usr/local/Cellar/yt-dlp/2023.6.22/libexec/lib/python3.11/site-packages/yt_dlp/YoutubeDL.py", line 3876, in print_debug_header
    self._setup_opener()
  File "/usr/local/Cellar/yt-dlp/2023.6.22/libexec/lib/python3.11/site-packages/yt_dlp/YoutubeDL.py", line 3920, in _setup_opener
    self.cookiejar = load_cookies(opts_cookiefile, opts_cookiesfrombrowser, self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/yt-dlp/2023.6.22/libexec/lib/python3.11/site-packages/yt_dlp/cookies.py", line 106, in load_cookies
    extract_cookies_from_browser(browser_name, profile, YDLLogger(ydl), keyring=keyring, container=container))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/yt-dlp/2023.6.22/libexec/lib/python3.11/site-packages/yt_dlp/cookies.py", line 125, in extract_cookies_from_browser
    return _extract_safari_cookies(profile, logger)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/yt-dlp/2023.6.22/libexec/lib/python3.11/site-packages/yt_dlp/cookies.py", line 529, in _extract_safari_cookies
    with open(cookies_path, 'rb') as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 1] Operation not permitted: '/Users/thecoderpro/Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies'
```