Files
pytchat-fork/pytchat/tool/dlworker.py
2020-02-03 22:01:54 +09:00

28 lines
729 B
Python

from . import parser
class DownloadWorker:
"""
DownloadWorker associates a download session with a block.
Parameter
----------
fetch :
download function of asyncdl
block :
Block object that includes chat_data
"""
def __init__(self, fetch, block):
self.block = block
self.fetch = fetch
async def run(self, session):
"""Remove extra chats just after ready_blocks(). """
continuation = self.block.start()
"""download loop """
while continuation:
chats, new_cont, fetched_last = await self.fetch(continuation, session)
continuation = self.block.fill(chats, new_cont, fetched_last )