Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/cannot_fetch_at_0_multithread'
Browse files Browse the repository at this point in the history
  • Loading branch information
taizan-hokuto committed Jan 31, 2020
2 parents bbf7a29 + 76f0c0e commit 9de7578
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pytchat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.2'
__version__ = '0.0.5.3'
__license__ = 'MIT'
__author__ = 'taizan-hokuto'
__author_email__ = '55448286+taizan-hokuto@users.noreply.github.com'
Expand Down
4 changes: 1 addition & 3 deletions pytchat/core_async/livechat.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class LiveChatAsync:
'''

_setup_finished = False
_logger = config.logger(__name__)

def __init__(self, video_id,
seektime = 0,
Expand Down Expand Up @@ -249,8 +248,7 @@ async def _get_livechat_json(self, continuation, session, headers):
continuation = urllib.parse.quote(continuation)
livechat_json = None
status_code = 0
url =(
f"https://www.youtube.com/{self._fetch_url}{continuation}&pbj=1")
url =f"https://www.youtube.com/{self._fetch_url}{continuation}&pbj=1"
for _ in range(MAX_RETRY + 1):
async with session.get(url ,headers = headers) as resp:
try:
Expand Down
9 changes: 7 additions & 2 deletions pytchat/core_multithread/livechat.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class LiveChat:
_setup_finished = False
#チャット監視中のListenerのリスト
_listeners = []
_logger = config.logger(__name__)

def __init__(self, video_id,
seektime = 0,
Expand Down Expand Up @@ -222,9 +221,15 @@ def _get_contents(self, continuation, session, headers):
'''Try to fetch archive chat data.'''
self._parser.is_replay = True
self._fetch_url = "live_chat_replay/get_live_chat_replay?continuation="
continuation = arcparam.getparam(self.video_id, self.seektime)
continuation = arcparam.getparam(
self.video_id, self.seektime, self._topchat_only)
livechat_json = ( self._get_livechat_json(
continuation, session, headers))
reload_continuation = self._parser.reload_continuation(
self._parser.get_contents(livechat_json))
if reload_continuation:
livechat_json = (self._get_livechat_json(
reload_continuation, session, headers))
contents = self._parser.get_contents(livechat_json)
self._first_fetch = False
return contents
Expand Down

0 comments on commit 9de7578

Please sign in to comment.