Cover all actions when checking id and type

This commit is contained in:
taizan-hokuto
2020-01-26 22:11:16 +09:00
parent a89503fe9e
commit c126d5b825
2 changed files with 11 additions and 12 deletions

View File

@@ -149,18 +149,18 @@ class Downloader:
self.blocks = ret self.blocks = ret
return self return self
def download_each_block(self): def download_blocks(self):
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
loop.run_until_complete(self._dl_block()) loop.run_until_complete(self._dl_allocate())
return self return self
async def _dl_block(self): async def _dl_allocate(self):
futures = [] tasks = []
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
futures = [self._dl_chunk(session, block) for block in self.blocks] tasks = [self._dl_task(session, block) for block in self.blocks]
return await asyncio.gather(*futures,return_exceptions=True) 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 if (block.temp_last != -1 and
block.last > block.temp_last): block.last > block.temp_last):
return return
@@ -246,7 +246,7 @@ class Downloader:
.remove_duplicate_head() .remove_duplicate_head()
.set_temporary_last() .set_temporary_last()
.remove_overwrap() .remove_overwrap()
.download_each_block() .download_blocks()
.remove_duplicate_tail() .remove_duplicate_tail()
.combine() .combine()
) )

View File

@@ -49,10 +49,9 @@ def get_offset(item):
return int(item['replayChatItemAction']["videoOffsetTimeMsec"]) return int(item['replayChatItemAction']["videoOffsetTimeMsec"])
def get_id(item): def get_id(item):
#return list((list(item['replayChatItemAction']["actions"][0].values())[0])['item'].values())[0]['id'] return list((list(item['replayChatItemAction']["actions"][0].values())[0])['item'].values())[0].get('id')
return list(item['replayChatItemAction']['actions'][0]['addChatItemAction']['item'].values())[0]['id']
def get_type(item): 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]