[niconico] fix: download video while sending heartbeat (#72)

default interval
pull/86/head
insaneracist 4 years ago
parent 709fe21782
commit 83f4566147

@ -254,6 +254,19 @@ class NiconicoIE(InfoExtractor):
}
}).encode())
heartbeat_url = '{}/{}?_format=json&_method=PUT'.format(session_api_endpoint['url'], session_response['data']['session']['id'])
heartbeat_headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
heartbeat = {
'data': json.dumps(session_response['data']),
'headers': heartbeat_headers,
'interval': session_api_data['heartbeat_lifetime'] / 2000,
'method': 'POST',
'url': heartbeat_url,
}
resolution = video_quality.get('resolution', {})
return {
@ -264,6 +277,7 @@ class NiconicoIE(InfoExtractor):
'vbr': float_or_none(video_quality.get('bitrate'), 1000),
'height': resolution.get('height'),
'width': resolution.get('width'),
'heartbeat': heartbeat,
}
def _real_extract(self, url):

@ -21,7 +21,7 @@ class Heartbeat(object):
method=params.get('method')
)
self.interval = params.get('interval')
self.interval = params.get('interval', 30)
self.stopped = False
self.thread = threading.Thread(target=self.__heartbeat, daemon=True)

Loading…
Cancel
Save