import subprocess import os import json def isMkvpropeditAvailable(): if subprocess.run("mkvpropedit"): print("mkvpropedit exists.") def getListOfSubtitles(filename): if not os.path.exists(filename): raise FileNotFoundError result = subprocess.run( ["mkvmerge", "-i", filename, "-F", "json"], capture_output=True ) if result.returncode == 0: info = json.loads(result.stdout) return { track["id"]: track["properties"]["language"] for track in info["tracks"] if track["type"] == "subtitles" } if __name__ == "__main__": getListOfSubtitles("/home/lukas/Downloads/test5.mkv")