[~] Refactor
This commit is contained in:
parent
4d2e9a3fd7
commit
5db573c025
@ -204,41 +204,37 @@ def tiktok_videos_fetch(
|
|||||||
error=0,
|
error=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
with multiprocessing.Pool(processes=1) as pool:
|
for o in tqdm.tqdm(meta):
|
||||||
for o in tqdm.tqdm(meta):
|
stats['total'] += 1
|
||||||
stats['total'] += 1
|
path = os.path.join(
|
||||||
path = os.path.join(
|
o['result_dir'],
|
||||||
o['result_dir'],
|
o['fname'],
|
||||||
o['fname'],
|
)
|
||||||
)
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
not os.path.exists(path) or
|
not os.path.exists(path) or
|
||||||
file_mime_type(path) in ['empty'] or
|
file_mime_type(path) in ['empty'] or
|
||||||
force
|
force
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
pool.apply(
|
tiktok_video_fetch.apply_async(
|
||||||
tiktok_video_fetch,
|
id=o['id'],
|
||||||
kwds=dict(
|
url=o['url'],
|
||||||
id=o['id'],
|
fname=o['fname'],
|
||||||
url=o['url'],
|
method=method,
|
||||||
fname=o['fname'],
|
method_str=method_str,
|
||||||
method=method,
|
result_dir=o['result_dir'],
|
||||||
method_str=method_str,
|
).wait()
|
||||||
result_dir=o['result_dir'],
|
stats['saved'] += 1
|
||||||
),
|
except KeyboardInterrupt:
|
||||||
)
|
break
|
||||||
stats['saved'] += 1
|
except:
|
||||||
except KeyboardInterrupt:
|
logger.error(json.dumps(dict(
|
||||||
break
|
msg=traceback.format_exc(),
|
||||||
except:
|
)))
|
||||||
logger.error(json.dumps(dict(
|
stats['error'] += 1
|
||||||
msg=traceback.format_exc(),
|
else:
|
||||||
)))
|
stats['skipped'] += 1
|
||||||
stats['error'] += 1
|
|
||||||
else:
|
|
||||||
stats['skipped'] += 1
|
|
||||||
|
|
||||||
return stats
|
return stats
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user