]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/downloader/external.py
[websockets] Add `WebSocketFragmentFD` (#399)
[yt-dlp.git] / yt_dlp / downloader / external.py
index 8a69b484700f8965d1cf81b3e1b925c5e7dd5031..28b1d4e2b4e7930e3d4886ac6beb9480cd172fda 100644 (file)
@@ -347,6 +347,10 @@ def available(cls, path=None):
         # TODO: Fix path for ffmpeg
         return FFmpegPostProcessor().available
 
+    def on_process_started(self, proc, stdin):
+        """ Override this in subclasses  """
+        pass
+
     def _call_downloader(self, tmpfilename, info_dict):
         urls = [f['url'] for f in info_dict.get('requested_formats', [])] or [info_dict['url']]
         ffpp = FFmpegPostProcessor(downloader=self)
@@ -474,6 +478,8 @@ def _call_downloader(self, tmpfilename, info_dict):
         self._debug_cmd(args)
 
         proc = subprocess.Popen(args, stdin=subprocess.PIPE, env=env)
+        if url in ('-', 'pipe:'):
+            self.on_process_started(proc, proc.stdin)
         try:
             retval = proc.wait()
         except BaseException as e:
@@ -482,7 +488,7 @@ def _call_downloader(self, tmpfilename, info_dict):
             # produces a file that is playable (this is mostly useful for live
             # streams). Note that Windows is not affected and produces playable
             # files (see https://github.com/ytdl-org/youtube-dl/issues/8300).
-            if isinstance(e, KeyboardInterrupt) and sys.platform != 'win32':
+            if isinstance(e, KeyboardInterrupt) and sys.platform != 'win32' and url not in ('-', 'pipe:'):
                 process_communicate_or_kill(proc, b'q')
             else:
                 proc.kill()