def _heartbeat(self, video_id: str, text: str) -> None:
"""
??????????????????????????????????????
:param video_id:
:param text:
"""
try:
self.logger.debug("?????XML: %s", text)
api_url = self.glossary[video_id][KeyDmc.API_URL]
# 1?????????????????????????
waiting = (self.glossary[video_id][KeyDmc.HEARTBEAT] / 1000) - 5
companion = self._extract_session_tag(text)
self.logger.debug("????XML: %s", companion)
session_id = self._extract_session_id_xml(text)
await asyncio.sleep(waiting)
async with self.session.post(
url=api_url + "/" + session_id,
params={"_format": "xml", "_method": "PUT"},
data=companion
) as response: # type: aiohttp.ClientResponse
res_text = await response.text()
await self._heartbeat(video_id, res_text)
except asyncio.CancelledError:
pass
评论列表
文章目录