From 956c7e2640afe7cb55d6d4e774a162c91f116d86 Mon Sep 17 00:00:00 2001 From: taizan-hokuto <55448286+taizan-hokuto@users.noreply.github.com> Date: Sat, 18 Jan 2020 17:50:31 +0900 Subject: [PATCH 1/4] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dfd9d1d..9b4a606 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Other features: instead of web scraping. For more detailed information, see [wiki](https://github.com/taizan-hokuto/pytchat/wiki).
-より詳細な解説は[wiki](https://github.com/taizan-hokuto/pytchat/wiki/Home-:)を参照してください。 +より詳細な解説は[wiki](https://github.com/taizan-hokuto/pytchat/wiki/Home:)を参照してください。 ## Install ```python @@ -267,4 +267,4 @@ Structure of author object. [taizan-hokuto](https://github.com/taizan-hokuto) -[twitter:@taizan205](https://twitter.com/taizan205) \ No newline at end of file +[twitter:@taizan205](https://twitter.com/taizan205) From 4e47d4a262565eba80bd18a4a5868bfb7ec604e7 Mon Sep 17 00:00:00 2001 From: taizan-hokuto <55448286+taizan-hokuto@users.noreply.github.com> Date: Fri, 31 Jan 2020 23:38:51 +0900 Subject: [PATCH 2/4] Fix for #1 --- pytchat/core_async/livechat.py | 5 +++++ pytchat/parser/live.py | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/pytchat/core_async/livechat.py b/pytchat/core_async/livechat.py index d22145f..a5e439c 100644 --- a/pytchat/core_async/livechat.py +++ b/pytchat/core_async/livechat.py @@ -233,6 +233,11 @@ class LiveChatAsync: self.video_id, self.seektime, self._topchat_only) livechat_json = (await self._get_livechat_json( continuation, session, headers)) + reload_continuation = self._parser.reload_continuation( + self._parser.get_contents(livechat_json)) + if reload_continuation: + livechat_json = (await self._get_livechat_json( + reload_continuation, session, headers)) contents = self._parser.get_contents(livechat_json) self._first_fetch = False return contents diff --git a/pytchat/parser/live.py b/pytchat/parser/live.py index 7429e50..a37bbaa 100644 --- a/pytchat/parser/live.py +++ b/pytchat/parser/live.py @@ -66,6 +66,23 @@ class Parser: raise ChatParseException('Cannot extract continuation data') return self._create_data(metadata, contents) + def reload_continuation(self, contents): + """ + When `seektime = 0` or seektime is abbreviated , + check if fetched chat json has no chat data. + If so, try to fetch playerSeekContinuationData. + This function must be run only first fetching. + """ + cont = contents['liveChatContinuation']['continuations'][0] + if cont.get("liveChatReplayContinuationData"): + #chat data exist. + return None + #chat data do not exist, get playerSeekContinuationData. + init_cont = cont.get("playerSeekContinuationData") + if init_cont: + return init_cont.get("continuation") + raise ChatParseException('Finished chat data') + def _create_data(self, metadata, contents): actions = contents['liveChatContinuation'].get('actions') if self.is_replay: From 053ff5291f77d7c788e55909c963df20ea1b23a8 Mon Sep 17 00:00:00 2001 From: taizan-hokuto <55448286+taizan-hokuto@users.noreply.github.com> Date: Fri, 31 Jan 2020 23:54:03 +0900 Subject: [PATCH 3/4] Modify url for japanese wiki --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b4a606..d38058a 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Other features: instead of web scraping. For more detailed information, see [wiki](https://github.com/taizan-hokuto/pytchat/wiki).
-より詳細な解説は[wiki](https://github.com/taizan-hokuto/pytchat/wiki/Home:)を参照してください。 +より詳細な解説は[wiki](https://github.com/taizan-hokuto/pytchat/wiki/Home_jp)を参照してください。 ## Install ```python From 1862b83eac6a04dd674650e075955e01dd748d0b Mon Sep 17 00:00:00 2001 From: taizan-hokuto <55448286+taizan-hokuto@users.noreply.github.com> Date: Fri, 31 Jan 2020 23:58:07 +0900 Subject: [PATCH 4/4] Increment version --- pytchat/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytchat/__init__.py b/pytchat/__init__.py index 0029913..bdaead1 100644 --- a/pytchat/__init__.py +++ b/pytchat/__init__.py @@ -2,7 +2,7 @@ pytchat is a python library for fetching youtube live chat without using yt api, Selenium, or BeautifulSoup. """ __copyright__ = 'Copyright (C) 2019 taizan-hokuto' -__version__ = '0.0.5.1.3' +__version__ = '0.0.5.2' __license__ = 'MIT' __author__ = 'taizan-hokuto' __author_email__ = '55448286+taizan-hokuto@users.noreply.github.com'