From 61ef98c688a72a579450d28ab3ede2a49fb8735e Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Sat, 3 Sep 2022 12:29:28 +0200 Subject: [PATCH] animetosho2mks: Use parallel processing --- animetosho2mks.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/animetosho2mks.py b/animetosho2mks.py index f4aa51e..9249b65 100755 --- a/animetosho2mks.py +++ b/animetosho2mks.py @@ -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)))