Enhance Avisynth video workflow and metadata tools
This commit is contained in:
+30
-7
@@ -34,7 +34,6 @@ from tools.video_batch_encode import encode_validated_video_only
|
||||
from tools.video_inputs import VideoInput, collect_video_inputs
|
||||
from tools.video_options import (
|
||||
ask_avisynth_runners,
|
||||
ask_encode_video_only,
|
||||
ask_ffms2_plugin_path,
|
||||
)
|
||||
from tools.video_probe import probe_video, require_tool
|
||||
@@ -206,7 +205,7 @@ def run(argv: list[str]) -> int:
|
||||
avs_runners,
|
||||
ffprobe,
|
||||
)
|
||||
elif ask_encode_video_only():
|
||||
elif _env_truthy("MBT_ENCODE_VIDEO"):
|
||||
encode_validated_video_only(
|
||||
root,
|
||||
inputs,
|
||||
@@ -229,6 +228,10 @@ def run(argv: list[str]) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
def _env_truthy(name: str) -> bool:
|
||||
return os.environ.get(name, "").strip().lower() in {"1", "true", "yes", "y", "on"}
|
||||
|
||||
|
||||
def print_workspace_summary(
|
||||
root: Path,
|
||||
inputs: list[VideoInput],
|
||||
@@ -257,19 +260,27 @@ def print_workspace_summary(
|
||||
|
||||
def delete_stale_visible_scripts(root: Path, inputs: list[VideoInput]) -> None:
|
||||
stale = stale_visible_scripts(root, inputs)
|
||||
if not stale:
|
||||
stale_manifests = stale_workspace_manifests(root)
|
||||
if not stale and not stale_manifests:
|
||||
return
|
||||
print("\nOld editable Avisynth scripts not used by this batch:")
|
||||
for script in stale:
|
||||
print(f" - {script}")
|
||||
if stale:
|
||||
print("\nOld editable Avisynth scripts not used by this batch:")
|
||||
for script in stale:
|
||||
print(f" - {script}")
|
||||
if stale_manifests:
|
||||
print("\nStale video manifest files:")
|
||||
for manifest in stale_manifests:
|
||||
print(f" - {manifest}")
|
||||
if sys.stdin.isatty():
|
||||
delete = prompt_yes_no("Delete old editable .avs scripts?", default=True)
|
||||
delete = prompt_yes_no("Delete listed stale workspace files?", default=True)
|
||||
else:
|
||||
delete = False
|
||||
if not delete:
|
||||
return
|
||||
for script in stale:
|
||||
script.unlink()
|
||||
for manifest in stale_manifests:
|
||||
manifest.unlink()
|
||||
|
||||
|
||||
def stale_visible_scripts(root: Path, inputs: list[VideoInput]) -> list[Path]:
|
||||
@@ -286,6 +297,18 @@ def stale_visible_scripts(root: Path, inputs: list[VideoInput]) -> list[Path]:
|
||||
return sorted(stale)
|
||||
|
||||
|
||||
def stale_workspace_manifests(root: Path) -> list[Path]:
|
||||
if not root.exists():
|
||||
return []
|
||||
return sorted(
|
||||
manifest
|
||||
for manifest in root.rglob("*.manifest.json")
|
||||
if not manifest.with_name(
|
||||
manifest.name.removesuffix(".manifest.json")
|
||||
).is_file()
|
||||
)
|
||||
|
||||
|
||||
def preflight_kept_visible_scripts(
|
||||
*,
|
||||
avs_runners,
|
||||
|
||||
Reference in New Issue
Block a user