From cc3fa8d39df5e954c26e62fdd77138f16a14e7a9 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Thu, 5 Aug 2021 01:11:05 +0530 Subject: [PATCH] Handle `BrokenPipeError` PR: https://github.com/ytdl-org/youtube-dl/pull/29505 Fixes: https://github.com/ytdl-org/youtube-dl/issues/29082 Authored by: kikuyan --- yt_dlp/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/yt_dlp/__init__.py b/yt_dlp/__init__.py index 552b0cb56..fb0f46a4a 100644 --- a/yt_dlp/__init__.py +++ b/yt_dlp/__init__.py @@ -734,6 +734,11 @@ def main(argv=None): sys.exit('ERROR: fixed output name but more than one file to download') except KeyboardInterrupt: sys.exit('\nERROR: Interrupted by user') + except BrokenPipeError: + # https://docs.python.org/3/library/signal.html#note-on-sigpipe + devnull = os.open(os.devnull, os.O_WRONLY) + os.dup2(devnull, sys.stdout.fileno()) + sys.exit(r'\nERROR: {err}') __all__ = ['main', 'YoutubeDL', 'gen_extractors', 'list_extractors']