[heartbeat] python2: remove explicit http method

pull/86/head
insaneracist 4 years ago
parent 89ada4406a
commit 12ab8cf6c5

@ -263,7 +263,6 @@ class NiconicoIE(InfoExtractor):
'data': json.dumps(session_response['data']),
'headers': heartbeat_headers,
'interval': session_api_data['heartbeat_lifetime'] / 2000,
'method': 'POST',
'url': heartbeat_url,
}

@ -18,11 +18,12 @@ class Heartbeat(object):
data = params.get('data')
if isinstance(data, compat_str):
data = data.encode()
# Python 2 does not allow us to set HTTP method
# it is POST if Request has data, otherwise GET
self.request = sanitized_Request(
params.get('url'),
data=data,
headers=params.get('headers', {}),
method=params.get('method')
headers=params.get('headers', {})
)
self.interval = params.get('interval', 30)
@ -49,7 +50,7 @@ class Heartbeat(object):
self.ydl.to_screen('[heartbeat]')
self.ydl.urlopen(self.request)
except Exception:
self.ydl.report_warning("[heartbeat] Heartbeat failed")
self.ydl.report_warning("Heartbeat failed")
if self.ydl.params.get('verbose'):
self.ydl.to_stderr(encode_compat_str(traceback.format_exc()))
self.parent_thread.join(self.interval)

Loading…
Cancel
Save