Return generator instead of list
This commit is contained in:
@@ -137,7 +137,7 @@ class DefaultProcessor(ChatProcessor):
|
|||||||
if component is None:
|
if component is None:
|
||||||
continue
|
continue
|
||||||
timeout += component.get('timeout', 0)
|
timeout += component.get('timeout', 0)
|
||||||
chatdata = component.get('chatdata')
|
chatdata = component.get('chatdata') # if from Extractor, chatdata is generator.
|
||||||
if chatdata is None:
|
if chatdata is None:
|
||||||
continue
|
continue
|
||||||
for action in chatdata:
|
for action in chatdata:
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from typing import Generator
|
||||||
from . import asyncdl
|
from . import asyncdl
|
||||||
from . import duplcheck
|
from . import duplcheck
|
||||||
from .. videoinfo import VideoInfo
|
from .. videoinfo import VideoInfo
|
||||||
@@ -60,11 +61,10 @@ class Extractor:
|
|||||||
self.blocks = duplcheck.remove_duplicate_tail(self.blocks)
|
self.blocks = duplcheck.remove_duplicate_tail(self.blocks)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def _combine(self):
|
def _get_chatdata(self) -> Generator:
|
||||||
ret = []
|
|
||||||
for block in self.blocks:
|
for block in self.blocks:
|
||||||
ret.extend(block.chat_data)
|
for chatdata in block.chat_data:
|
||||||
return ret
|
yield chatdata
|
||||||
|
|
||||||
def _execute_extract_operations(self):
|
def _execute_extract_operations(self):
|
||||||
return (
|
return (
|
||||||
@@ -74,7 +74,7 @@ class Extractor:
|
|||||||
._remove_overlap()
|
._remove_overlap()
|
||||||
._download_blocks()
|
._download_blocks()
|
||||||
._remove_duplicate_tail()
|
._remove_duplicate_tail()
|
||||||
._combine()
|
._get_chatdata()
|
||||||
)
|
)
|
||||||
|
|
||||||
def extract(self):
|
def extract(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user