Merge branch 'hotfix/cannot_fetch_at_0_multithread'

This commit is contained in:
taizan-hokuto
2020-02-01 01:41:40 +09:00
3 changed files with 9 additions and 6 deletions

View File

@@ -2,7 +2,7 @@
pytchat is a python library for fetching youtube live chat without using yt api, Selenium, or BeautifulSoup. pytchat is a python library for fetching youtube live chat without using yt api, Selenium, or BeautifulSoup.
""" """
__copyright__ = 'Copyright (C) 2019 taizan-hokuto' __copyright__ = 'Copyright (C) 2019 taizan-hokuto'
__version__ = '0.0.5.2' __version__ = '0.0.5.3'
__license__ = 'MIT' __license__ = 'MIT'
__author__ = 'taizan-hokuto' __author__ = 'taizan-hokuto'
__author_email__ = '55448286+taizan-hokuto@users.noreply.github.com' __author_email__ = '55448286+taizan-hokuto@users.noreply.github.com'

View File

@@ -73,7 +73,6 @@ class LiveChatAsync:
''' '''
_setup_finished = False _setup_finished = False
_logger = config.logger(__name__)
def __init__(self, video_id, def __init__(self, video_id,
seektime = 0, seektime = 0,
@@ -249,8 +248,7 @@ class LiveChatAsync:
continuation = urllib.parse.quote(continuation) continuation = urllib.parse.quote(continuation)
livechat_json = None livechat_json = None
status_code = 0 status_code = 0
url =( url =f"https://www.youtube.com/{self._fetch_url}{continuation}&pbj=1"
f"https://www.youtube.com/{self._fetch_url}{continuation}&pbj=1")
for _ in range(MAX_RETRY + 1): for _ in range(MAX_RETRY + 1):
async with session.get(url ,headers = headers) as resp: async with session.get(url ,headers = headers) as resp:
try: try:

View File

@@ -74,7 +74,6 @@ class LiveChat:
_setup_finished = False _setup_finished = False
#チャット監視中のListenerのリスト #チャット監視中のListenerのリスト
_listeners = [] _listeners = []
_logger = config.logger(__name__)
def __init__(self, video_id, def __init__(self, video_id,
seektime = 0, seektime = 0,
@@ -222,9 +221,15 @@ class LiveChat:
'''Try to fetch archive chat data.''' '''Try to fetch archive chat data.'''
self._parser.is_replay = True self._parser.is_replay = True
self._fetch_url = "live_chat_replay/get_live_chat_replay?continuation=" 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( livechat_json = ( self._get_livechat_json(
continuation, session, headers)) 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) contents = self._parser.get_contents(livechat_json)
self._first_fetch = False self._first_fetch = False
return contents return contents