From 46a5b335e708c81bb6e9eb8cef0c13c72c497f0a Mon Sep 17 00:00:00 2001 From: pukkandan Date: Mon, 26 Sep 2022 02:53:08 +0530 Subject: [PATCH] [cookies] Let `_get_mac_keyring_password` fail gracefully Closes #4915 --- yt_dlp/cookies.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/yt_dlp/cookies.py b/yt_dlp/cookies.py index 24a8250da..3032d0712 100644 --- a/yt_dlp/cookies.py +++ b/yt_dlp/cookies.py @@ -845,12 +845,15 @@ def _get_linux_keyring_password(browser_keyring_name, keyring, logger): def _get_mac_keyring_password(browser_keyring_name, logger): logger.debug('using find-generic-password to obtain password from OSX keychain') try: - stdout, _, _ = Popen.run( + stdout, _, returncode = Popen.run( ['security', 'find-generic-password', '-w', # write password to stdout '-a', browser_keyring_name, # match 'account' '-s', f'{browser_keyring_name} Safe Storage'], # match 'service' stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) + if returncode: + logger.warning('find-generic-password failed') + return None return stdout.rstrip(b'\n') except Exception as e: logger.warning(f'exception running find-generic-password: {error_to_str(e)}')