animetosho2mks: Use parallel processing

This commit is contained in:
Simon Bruder 2022-09-03 12:29:28 +02:00
parent b31f03679b
commit 61ef98c688
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC

View file

@ -1,9 +1,11 @@
#!/usr/bin/env cached-nix-shell
#!nix-shell -i python3 -p "python3.withPackages(ps: [ ps.tqdm ])" mkvtoolnix-cli
from subprocess import run
from tqdm import tqdm
import glob
import multiprocessing
import os.path
from subprocess import run
from tqdm import tqdm
class SubtitleTrack:
@ -69,5 +71,8 @@ class AnimeToshoFile:
run(command, check=True)
for file in tqdm(list(map(AnimeToshoFile, glob.glob("*.mkv")))):
file.merge()
files = list(map(AnimeToshoFile, glob.glob("*.mkv")))
with multiprocessing.Pool() as pool:
list(tqdm(pool.imap_unordered(AnimeToshoFile.merge, files), total=len(files)))