diff --git a/pytchat/core_async/replaychat.py b/pytchat/core_async/replaychat.py index ab5fd5b..45f0c6e 100644 --- a/pytchat/core_async/replaychat.py +++ b/pytchat/core_async/replaychat.py @@ -136,7 +136,7 @@ class ReplayChatAsync: """最初のcontinuationパラメータを取得し、 _listenループのタスクを作成し開始する """ - initial_continuation = arcparam.get(self.video_id,self.seektime) + initial_continuation = arcparam.getparam(self.video_id, self.seektime) await self._listen(initial_continuation) async def _listen(self, continuation): @@ -159,7 +159,7 @@ class ReplayChatAsync: prohibit from blocking by putting None into _pauser. ''' self._pauser.put_nowait(None) - #continuation= arcparam.get(self.video_id) + #when replay, not reacquire continuation param livechat_json = (await self._get_livechat_json(continuation, session, headers) ) diff --git a/pytchat/core_multithread/replaychat.py b/pytchat/core_multithread/replaychat.py index 43b5e2e..10106ca 100644 --- a/pytchat/core_multithread/replaychat.py +++ b/pytchat/core_multithread/replaychat.py @@ -139,7 +139,7 @@ class ReplayChat: def _get_initial_continuation(self): ''' チャットデータ取得に必要な最初のcontinuationを取得する。''' try: - initial_continuation = arcparam.get(self.video_id,self.seektime) + initial_continuation = arcparam.getparam(self.video_id,self.seektime) except ChatParseException as e: self.terminate() logger.debug(f"[{self.video_id}]Error:{str(e)}") diff --git a/pytchat/paramgen/arcparam.py b/pytchat/paramgen/arcparam.py index 6cc7650..45da2c7 100644 --- a/pytchat/paramgen/arcparam.py +++ b/pytchat/paramgen/arcparam.py @@ -65,7 +65,7 @@ def _tzparity(video_id,times): return ((times^t) % 2).to_bytes(1,'big') -def get(video_id, seektime = 0, topchatonly = False): +def _build(video_id, seektime, topchatonly = False): switch_01 = b'\x04' if topchatonly else b'\x01' @@ -116,5 +116,11 @@ def get(video_id, seektime = 0, topchatonly = False): ).decode() ) - - +def getparam(video_id, seektime = 0): + ''' + Parameter + --------- + seektime : int + seconds to load past chat data + ''' + return _build(video_id, seektime) diff --git a/tests/test_arcparam.py b/tests/test_arcparam.py index 926dd59..e53eda3 100644 --- a/tests/test_arcparam.py +++ b/tests/test_arcparam.py @@ -5,16 +5,16 @@ import requests, json from pytchat.paramgen import arcparam def test_arcparam_0(mocker): - param = arcparam.get("01234567890") + param = arcparam.getparam("01234567890") assert "op2w0wRyGjxDZzhhRFFvTE1ERXlNelExTmpjNE9UQWFFLXFvM2JrQkRRb0xNREV5TXpRMU5qYzRPVEFnQVElM0QlM0QoATAAOABAAEgEUhwIABAAGAAgACoOc3RhdGljY2hlY2tzdW1AAFgDYAFoAXIECAEQAXgA" == param def test_arcparam_1(mocker): - param = arcparam.get("01234567890", seektime = 100000) + param = arcparam.getparam("01234567890", seektime = 100000) assert "op2w0wR3GjxDZzhhRFFvTE1ERXlNelExTmpjNE9UQWFFLXFvM2JrQkRRb0xNREV5TXpRMU5qYzRPVEFnQVElM0QlM0QogNDbw_QCMAA4AEAASANSHAgAEAAYACAAKg5zdGF0aWNjaGVja3N1bUAAWANgAWgBcgQIARABeAA%3D" == param def test_arcparam_2(mocker): - param = arcparam.get("SsjCnHOk-Sk") + param = arcparam.getparam("SsjCnHOk-Sk") url=f"https://www.youtube.com/live_chat_replay/get_live_chat_replay?continuation={param}&pbj=1" resp = requests.Session().get(url,headers = config.headers) jsn = json.loads(resp.text)