[~] Refactor
This commit is contained in:
parent
450cab746e
commit
ec7e2712eb
@ -8,6 +8,7 @@ RUN pip3 install numpy pandas browser_cookie3 ipdb asgiref
|
|||||||
RUN python3 -m playwright install-deps
|
RUN python3 -m playwright install-deps
|
||||||
RUN python3 -m playwright install
|
RUN python3 -m playwright install
|
||||||
RUN pip3 install tqdm
|
RUN pip3 install tqdm
|
||||||
|
RUN apt-get install -yy ffmpeg
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
@ -259,3 +259,43 @@ def tiktok_videos_fetch(
|
|||||||
stats['skipped'] += 1
|
stats['skipped'] += 1
|
||||||
|
|
||||||
return stats
|
return stats
|
||||||
|
|
||||||
|
def tiktok_videos_process(meta: Iterable[dict[str, Any]]) -> dict[str, Any]:
|
||||||
|
import tqdm
|
||||||
|
stats = dict(
|
||||||
|
saved=0,
|
||||||
|
total=0,
|
||||||
|
skipped=0,
|
||||||
|
error=0,
|
||||||
|
)
|
||||||
|
|
||||||
|
for o in tqdm.tqdm(meta):
|
||||||
|
stats['total'] += 1
|
||||||
|
|
||||||
|
path = os.path.join(
|
||||||
|
o['result_dir'],
|
||||||
|
o['fname'],
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
path_parts = os.path.splitext(path)
|
||||||
|
|
||||||
|
processed_path = path_parts[0] + '-proc' + path_parts[1]
|
||||||
|
|
||||||
|
if not os.path.exists(path) or os.path.exists(processed_path):
|
||||||
|
stats['skipped'] += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
subprocess.check_call([
|
||||||
|
'ffmpeg','-i', path, '-filter:v', 'setpts=0.5*PTS', processed_path,
|
||||||
|
])
|
||||||
|
stats['saved'] += 1
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
logger.error(json.dumps(dict(
|
||||||
|
msg=traceback.format_exc(),
|
||||||
|
)))
|
||||||
|
stats['error'] += 1
|
||||||
|
|
||||||
|
return stats
|
||||||
|
Loading…
Reference in New Issue
Block a user