Add no-op guard

This commit is contained in:
Olivier 'reivilibre' 2022-11-21 12:57:12 +00:00
parent dfc61b04a6
commit 6969e4d7cb
1 changed files with 13 additions and 0 deletions

View File

@ -23,6 +23,15 @@ def has_audio_in_lang(meta: Dict[str, Any], lang: str) -> bool:
return False
def has_audio_not_in_lang(meta: Dict[str, Any], lang: str) -> bool:
for stream in meta["streams"]:
if stream["codec_type"] == "audio":
if stream.get("tags", {}).get("language") != lang:
return True
return False
def make_dubstrip_command(
file: Path, outfile: Path, meta: Dict[str, Any], keep_lang: str
) -> List[Union[str, Path]]:
@ -55,6 +64,10 @@ def main() -> None:
print(f"no audio in {args.keep}: leaving untouched.")
continue
if not has_audio_not_in_lang(meta, args.keep):
print(f"no audio not in {args.keep}: nothing to do.")
continue
outfile = file.parent.joinpath("dubstriptmp-" + file.name)
cmd = make_dubstrip_command(file, outfile, meta, args.keep)