diff options
author | Nam Vu <git@yuru.moe> | 2023-05-29 15:05:51 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-29 11:35:51 +0530 |
commit | a58182b75a05fe0a10c5e94a536711d3ade19c20 (patch) | |
tree | 74f7123cfda3e09def506cabddf34b803b825b5d /yt_dlp/cookies.py | |
parent | 4afb208cf07b59291ae3b0c4efc83945ee5b8812 (diff) | |
download | hypervideo-pre-a58182b75a05fe0a10c5e94a536711d3ade19c20.tar.lz hypervideo-pre-a58182b75a05fe0a10c5e94a536711d3ade19c20.tar.xz hypervideo-pre-a58182b75a05fe0a10c5e94a536711d3ade19c20.zip |
[cookies] Support custom Safari cookies path (#6783)
Authored by: NextFire
Diffstat (limited to 'yt_dlp/cookies.py')
-rw-r--r-- | yt_dlp/cookies.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/yt_dlp/cookies.py b/yt_dlp/cookies.py index eb6a2656b..ee2af0f70 100644 --- a/yt_dlp/cookies.py +++ b/yt_dlp/cookies.py @@ -495,18 +495,22 @@ class WindowsChromeCookieDecryptor(ChromeCookieDecryptor): def _extract_safari_cookies(profile, logger): - if profile is not None: - logger.error('safari does not support profiles') if sys.platform != 'darwin': raise ValueError(f'unsupported platform: {sys.platform}') - cookies_path = os.path.expanduser('~/Library/Cookies/Cookies.binarycookies') + if profile: + cookies_path = os.path.expanduser(profile) + if not os.path.isfile(cookies_path): + raise FileNotFoundError('custom safari cookies database not found') + + else: + cookies_path = os.path.expanduser('~/Library/Cookies/Cookies.binarycookies') - if not os.path.isfile(cookies_path): - logger.debug('Trying secondary cookie location') - cookies_path = os.path.expanduser('~/Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies') if not os.path.isfile(cookies_path): - raise FileNotFoundError('could not find safari cookies database') + logger.debug('Trying secondary cookie location') + cookies_path = os.path.expanduser('~/Library/Containers/com.apple.Safari/Data/Library/Cookies/Cookies.binarycookies') + if not os.path.isfile(cookies_path): + raise FileNotFoundError('could not find safari cookies database') with open(cookies_path, 'rb') as f: cookies_data = f.read() |