From 69b59b4b4b52e496df980d8d21ad5ff670089c0b Mon Sep 17 00:00:00 2001 From: Lesmiscore Date: Mon, 25 Apr 2022 00:45:19 +0900 Subject: [PATCH] [downloader/fc2] Stop heatbeating once FFmpeg finishes Authored by: Lesmiscore --- yt_dlp/downloader/fc2.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/yt_dlp/downloader/fc2.py b/yt_dlp/downloader/fc2.py index d503aac04..f9763debb 100644 --- a/yt_dlp/downloader/fc2.py +++ b/yt_dlp/downloader/fc2.py @@ -18,6 +18,9 @@ def real_download(self, filename, info_dict): heartbeat_state = [None, 1] def heartbeat(): + if heartbeat_state[1] < 0: + return + try: heartbeat_state[1] += 1 ws.send('{"name":"heartbeat","arguments":{},"id":%d}' % heartbeat_state[1]) @@ -36,4 +39,8 @@ def heartbeat(): 'ws': None, 'protocol': 'live_ffmpeg', }) - return FFmpegFD(self.ydl, self.params or {}).download(filename, new_info_dict) + try: + return FFmpegFD(self.ydl, self.params or {}).download(filename, new_info_dict) + finally: + # stop heartbeating + heartbeat_state[1] = -1