Skip to content
Extraits de code Groupes Projets
Valider 3482b96f rédigé par Sting's avatar Sting
Parcourir les fichiers

Replace sed call

parent f3839d7c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!6Windows compat
...@@ -3,6 +3,8 @@ import argparse ...@@ -3,6 +3,8 @@ import argparse
import subprocess import subprocess
import shlex import shlex
from pathlib import Path from pathlib import Path
import re
...@@ -12,7 +14,9 @@ def extract_subtitles(source_file, output_file=None): ...@@ -12,7 +14,9 @@ def extract_subtitles(source_file, output_file=None):
else: else:
out_path = output_file out_path = output_file
data = subprocess.run(f'mkvmerge --identify "{source_file:s}" | sed -n "s/Track ID \\([[:digit:]]*\\).*subtitles.*/\\1/p"', capture_output=True, shell=True, text=True) data = subprocess.run(f'mkvmerge --identify "{source_file:s}"', capture_output=True, shell=True, text=True)
track_id = data.stdout.rstrip() RGX_TRACK = re.compile(r"Track ID (\d+): subtitles")
matches = RGX_TRACK.findall(data.stdout)
track_id = matches[0][0]
subprocess.call(shlex.split(f'mkvextract "{source_file:s}" tracks "{track_id:s}":"{out_path:s}"')) subprocess.call(shlex.split(f'mkvextract "{source_file:s}" tracks "{track_id:s}":"{out_path:s}"'))
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter