diff options
Diffstat (limited to 'hypervideo_dl/downloader/fc2.py')
-rw-r--r-- | hypervideo_dl/downloader/fc2.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/hypervideo_dl/downloader/fc2.py b/hypervideo_dl/downloader/fc2.py index 157bcf2..f9763de 100644 --- a/hypervideo_dl/downloader/fc2.py +++ b/hypervideo_dl/downloader/fc2.py @@ -1,5 +1,3 @@ -from __future__ import division, unicode_literals - import threading from .common import FileDownloader @@ -20,6 +18,9 @@ class FC2LiveFD(FileDownloader): 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]) @@ -38,4 +39,8 @@ class FC2LiveFD(FileDownloader): '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 |