chore: remove unused imports and dead code
This commit is contained in:
1 parent
2474a3662a
commit
a72cf4ad9c
5 files changed
+6
-77
No files matched your search
@@ -25,7 +25,6 @@ import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import numpy as np
|
||||
|
||||
try:
|
||||
import whisper
|
||||
@@ -195,41 +194,6 @@ def get_lang_name(code: str) -> str:
|
||||
return LANG_NAMES.get(code, code.upper())
|
||||
|
||||
|
||||
def apply_metadata(file_path: str, stream_idx: int, lang_code_3: str,
|
||||
title: str, dry_run: bool = True) -> str:
|
||||
"""
|
||||
Apply language metadata to a specific audio stream.
|
||||
Returns the ffmpeg command (for display) or runs it.
|
||||
"""
|
||||
# Use 3-letter ISO 639-2/B code for MKV
|
||||
meta_key = f"metadata:s:a:{stream_idx}"
|
||||
|
||||
cmd = [
|
||||
"ffmpeg", "-y",
|
||||
"-i", file_path,
|
||||
"-map", "0",
|
||||
"-c", "copy",
|
||||
f"{meta_key}:language={lang_code_3}",
|
||||
f"{meta_key}:title={title}",
|
||||
]
|
||||
|
||||
if dry_run:
|
||||
return " ".join(cmd)
|
||||
|
||||
# Write to temp file, then replace
|
||||
base, ext = os.path.splitext(file_path)
|
||||
tmp_out = f"{tmp_out_base}{ext}"
|
||||
cmd.append(tmp_out)
|
||||
|
||||
r = subprocess.run(cmd, capture_output=True, timeout=300)
|
||||
if r.returncode != 0:
|
||||
print(f" ERROR: ffmpeg metadata failed: {r.stderr.decode()[-200:]}", file=sys.stderr)
|
||||
return ""
|
||||
|
||||
# Replace original
|
||||
shutil.move(tmp_out, file_path)
|
||||
return file_path
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser(description="Detect audio languages via Whisper and set MKV metadata")
|
||||
|
||||
Reference in new issue
Block a user