mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 06:10:12 +01:00
[cookies] Support custom Safari cookies path (#6783)
Authored by: NextFire
This commit is contained in:
parent
4afb208cf0
commit
a58182b75a
|
@ -495,18 +495,22 @@ def decrypt(self, encrypted_value):
|
||||||
|
|
||||||
|
|
||||||
def _extract_safari_cookies(profile, logger):
|
def _extract_safari_cookies(profile, logger):
|
||||||
if profile is not None:
|
|
||||||
logger.error('safari does not support profiles')
|
|
||||||
if sys.platform != 'darwin':
|
if sys.platform != 'darwin':
|
||||||
raise ValueError(f'unsupported platform: {sys.platform}')
|
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):
|
|
||||||
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):
|
if not os.path.isfile(cookies_path):
|
||||||
raise FileNotFoundError('could not find safari cookies database')
|
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')
|
||||||
|
|
||||||
with open(cookies_path, 'rb') as f:
|
with open(cookies_path, 'rb') as f:
|
||||||
cookies_data = f.read()
|
cookies_data = f.read()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user