diff --git a/pytchat/tool/downloader.py b/pytchat/tool/downloader.py index def0a72..e79c36d 100644 --- a/pytchat/tool/downloader.py +++ b/pytchat/tool/downloader.py @@ -149,18 +149,18 @@ class Downloader: self.blocks = ret return self - def download_each_block(self): + def download_blocks(self): loop = asyncio.get_event_loop() - loop.run_until_complete(self._dl_block()) + loop.run_until_complete(self._dl_allocate()) return self - async def _dl_block(self): - futures = [] + async def _dl_allocate(self): + tasks = [] async with aiohttp.ClientSession() as session: - futures = [self._dl_chunk(session, block) for block in self.blocks] - return await asyncio.gather(*futures,return_exceptions=True) + tasks = [self._dl_task(session, block) for block in self.blocks] + return await asyncio.gather(*tasks,return_exceptions=True) - async def _dl_chunk(self, session, block:Block): + async def _dl_task(self, session, block:Block): if (block.temp_last != -1 and block.last > block.temp_last): return @@ -246,7 +246,7 @@ class Downloader: .remove_duplicate_head() .set_temporary_last() .remove_overwrap() - .download_each_block() + .download_blocks() .remove_duplicate_tail() .combine() - ) \ No newline at end of file + ) diff --git a/pytchat/tool/parser.py b/pytchat/tool/parser.py index 37bb6fd..8b046bd 100644 --- a/pytchat/tool/parser.py +++ b/pytchat/tool/parser.py @@ -49,10 +49,9 @@ def get_offset(item): return int(item['replayChatItemAction']["videoOffsetTimeMsec"]) def get_id(item): - #return list((list(item['replayChatItemAction']["actions"][0].values())[0])['item'].values())[0]['id'] - return list(item['replayChatItemAction']['actions'][0]['addChatItemAction']['item'].values())[0]['id'] + return list((list(item['replayChatItemAction']["actions"][0].values())[0])['item'].values())[0].get('id') def get_type(item): - return list(item['replayChatItemAction']["actions"][0]['addChatItemAction']['item'].keys())[0] + return list((list(item['replayChatItemAction']["actions"][0].values())[0])['item'].keys())[0]