map function call local function
This commit is contained in:
@@ -77,36 +77,34 @@ def getStoryline(number, title, sites: list=None):
|
|||||||
|
|
||||||
|
|
||||||
def getStoryline_mp(args):
|
def getStoryline_mp(args):
|
||||||
return _getStoryline_mp(*args)
|
def _inner(site, number, title, debug):
|
||||||
|
start_time = time.time()
|
||||||
|
storyline = None
|
||||||
# 注:新进程的print()不会写入日志中,将来调试修复失效数据源需直接查看标准输出,issue信息需截图屏幕
|
if not isinstance(site, str):
|
||||||
def _getStoryline_mp(site, number, title, debug):
|
return storyline
|
||||||
start_time = time.time()
|
elif site == "airavwiki":
|
||||||
storyline = None
|
storyline = getStoryline_airavwiki(number, debug)
|
||||||
if not isinstance(site, str):
|
elif site == "airav":
|
||||||
|
storyline = getStoryline_airav(number, debug)
|
||||||
|
elif site == "avno1":
|
||||||
|
storyline = getStoryline_avno1(number, debug)
|
||||||
|
elif site == "xcity":
|
||||||
|
storyline = getStoryline_xcity(number, debug)
|
||||||
|
elif site == "amazon":
|
||||||
|
storyline = getStoryline_amazon(title, number, debug)
|
||||||
|
elif site == "58avgo":
|
||||||
|
storyline = getStoryline_58avgo(number, debug)
|
||||||
|
if not debug:
|
||||||
|
return storyline
|
||||||
|
# 进程池模式的子进程getStoryline_*()的print()不会写入日志中,线程池和顺序执行不受影响
|
||||||
|
print("[!]MP 进程[{}]运行{:.3f}秒,结束于{}返回结果: {}".format(
|
||||||
|
site,
|
||||||
|
time.time() - start_time,
|
||||||
|
time.strftime("%H:%M:%S"),
|
||||||
|
storyline if isinstance(storyline, str) and len(storyline) else '[空]')
|
||||||
|
)
|
||||||
return storyline
|
return storyline
|
||||||
elif site == "airavwiki":
|
return _inner(*args)
|
||||||
storyline = getStoryline_airavwiki(number, debug)
|
|
||||||
elif site == "airav":
|
|
||||||
storyline = getStoryline_airav(number, debug)
|
|
||||||
elif site == "avno1":
|
|
||||||
storyline = getStoryline_avno1(number, debug)
|
|
||||||
elif site == "xcity":
|
|
||||||
storyline = getStoryline_xcity(number, debug)
|
|
||||||
elif site == "amazon":
|
|
||||||
storyline = getStoryline_amazon(title, number, debug)
|
|
||||||
elif site == "58avgo":
|
|
||||||
storyline = getStoryline_58avgo(number, debug)
|
|
||||||
if not debug:
|
|
||||||
return storyline
|
|
||||||
print("[!]MP 进程[{}]运行{:.3f}秒,结束于{}返回结果: {}".format(
|
|
||||||
site,
|
|
||||||
time.time() - start_time,
|
|
||||||
time.strftime("%H:%M:%S"),
|
|
||||||
storyline if isinstance(storyline, str) and len(storyline) else '[空]')
|
|
||||||
)
|
|
||||||
return storyline
|
|
||||||
|
|
||||||
|
|
||||||
def getStoryline_airav(number, debug):
|
def getStoryline_airav(number, debug):
|
||||||
|
|||||||
14
core.py
14
core.py
@@ -217,14 +217,12 @@ def extrafanart_download_one_by_one(data, path, filepath):
|
|||||||
print(f'[!]Extrafanart download one by one mode runtime {time.perf_counter() - tm_start:.3f}s')
|
print(f'[!]Extrafanart download one by one mode runtime {time.perf_counter() - tm_start:.3f}s')
|
||||||
|
|
||||||
def download_one_file(args):
|
def download_one_file(args):
|
||||||
return _download_one_file(*args)
|
def _inner(url: str, save_path: Path):
|
||||||
|
filebytes = get_html(url, return_type='content')
|
||||||
def _download_one_file(url: str, save_path: Path):
|
if isinstance(filebytes, bytes) and len(filebytes):
|
||||||
filebytes = get_html(url, return_type='content')
|
if len(filebytes) == save_path.open('wb').write(filebytes):
|
||||||
if isinstance(filebytes, bytes) and len(filebytes):
|
return str(save_path)
|
||||||
if len(filebytes) == save_path.open('wb').write(filebytes):
|
return _inner(*args)
|
||||||
return str(save_path)
|
|
||||||
return None
|
|
||||||
|
|
||||||
def extrafanart_download_threadpool(url_list, save_dir, number):
|
def extrafanart_download_threadpool(url_list, save_dir, number):
|
||||||
tm_start = time.perf_counter()
|
tm_start = time.perf_counter()
|
||||||
|
|||||||
Reference in New Issue
Block a user