yt-dlp: Cannot get cookies from Safari.

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

  • I understand that I will be blocked if I intentionally remove or skip any mandatory* field

Checklist

  • I’m reporting a bug unrelated to a specific site
  • I’ve verified that I’m running yt-dlp version 2023.06.22 (update instructions) or later (specify commit)
  • I’ve checked that all provided URLs are playable in a browser with the same IP and same login details
  • I’ve checked that all URLs and arguments with special characters are properly quoted or escaped
  • I’ve searched known issues and the bugtracker for similar issues including closed ones. DO NOT post duplicates
  • I’ve read the guidelines for 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

  • 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
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

[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'

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 2
  • Comments: 15 (7 by maintainers)

Most upvoted comments

You can get around this by going into System Preferences > Security & Privacy and giving Full Disk Access to Terminal.

In that case, all we can do is improve the error message

You can get around this by going into System Preferences > Security & Privacy and giving Full Disk Access to Terminal.

Is this possible on windows 10? Opening the System Preferences, the Security option gives no option for disck access