nicodown_async.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:niconico-tools 作者: mo-san 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号