3 from .common
import FileDownloader
4 from .external
import FFmpegFD
7 class FC2LiveFD(FileDownloader
):
9 Downloads FC2 live without being stopped. <br>
10 Note, this is not a part of public API, and will be removed without notice.
14 def real_download(self
, filename
, info_dict
):
17 heartbeat_lock
= threading
.Lock()
18 heartbeat_state
= [None, 1]
21 if heartbeat_state
[1] < 0:
25 heartbeat_state
[1] += 1
26 ws
.send('{"name":"heartbeat","arguments":{},"id":%d}' % heartbeat_state
[1])
28 self
.to_screen('[fc2:live] Heartbeat failed')
31 heartbeat_state
[0] = threading
.Timer(30, heartbeat
)
32 heartbeat_state
[0]._daemonic
= True
33 heartbeat_state
[0].start()
37 new_info_dict
= info_dict
.copy()
38 new_info_dict
.update({
40 'protocol': 'live_ffmpeg',
43 return FFmpegFD(self
.ydl
, self
.params
or {}).download(filename
, new_info_dict
)
46 heartbeat_state
[1] = -1