Delete unnecessary lines
This commit is contained in:
@@ -161,19 +161,7 @@ class LiveChatAsync:
|
|||||||
livechat_json = (await
|
livechat_json = (await
|
||||||
self._get_livechat_json(continuation, session, headers)
|
self._get_livechat_json(continuation, session, headers)
|
||||||
)
|
)
|
||||||
contents = self._parser.get_contents(livechat_json)
|
contents = await self._get_contents(livechat_json, session, headers)
|
||||||
'''switch live or replay'''
|
|
||||||
if self._first_fetch:
|
|
||||||
if contents is None:
|
|
||||||
self._parser.mode = 'REPLAY'
|
|
||||||
self._fetch_url = ("live_chat_replay/"
|
|
||||||
"get_live_chat_replay?continuation=")
|
|
||||||
continuation = arcparam.getparam(self.video_id)
|
|
||||||
livechat_json = (await self._get_livechat_json(
|
|
||||||
continuation, session, headers))
|
|
||||||
contents = self._parser.get_contents(livechat_json)
|
|
||||||
self._first_fetch = False
|
|
||||||
|
|
||||||
metadata, chatdata = self._parser.parse( contents )
|
metadata, chatdata = self._parser.parse( contents )
|
||||||
|
|
||||||
timeout = metadata['timeoutMs']/1000
|
timeout = metadata['timeoutMs']/1000
|
||||||
@@ -204,6 +192,29 @@ class LiveChatAsync:
|
|||||||
logger.debug(f"[{self.video_id}]チャット取得を終了しました。")
|
logger.debug(f"[{self.video_id}]チャット取得を終了しました。")
|
||||||
self.terminate()
|
self.terminate()
|
||||||
|
|
||||||
|
async def _get_contents(self, livechat_json, session, headers):
|
||||||
|
'''Get 'contents' dict from livechat json.
|
||||||
|
If contents is None at first fetching,
|
||||||
|
try to fetch archive chat data.
|
||||||
|
|
||||||
|
Return:
|
||||||
|
-------
|
||||||
|
'contents' dict which includes metadata & chatdata.
|
||||||
|
'''
|
||||||
|
contents = self._parser.get_contents(livechat_json)
|
||||||
|
if self._first_fetch:
|
||||||
|
if contents is None:
|
||||||
|
'''Try to fetch archive chat data.'''
|
||||||
|
self._parser.mode = 'REPLAY'
|
||||||
|
self._fetch_url = ("live_chat_replay/"
|
||||||
|
"get_live_chat_replay?continuation=")
|
||||||
|
continuation = arcparam.getparam(self.video_id)
|
||||||
|
livechat_json = (await self._get_livechat_json(
|
||||||
|
continuation, session, headers))
|
||||||
|
contents = self._parser.get_contents(livechat_json)
|
||||||
|
self._first_fetch = False
|
||||||
|
return contents
|
||||||
|
|
||||||
async def _get_livechat_json(self, continuation, session, headers):
|
async def _get_livechat_json(self, continuation, session, headers):
|
||||||
'''
|
'''
|
||||||
チャットデータが格納されたjsonデータを取得する。
|
チャットデータが格納されたjsonデータを取得する。
|
||||||
|
|||||||
Reference in New Issue
Block a user