from __future__ import annotations
import json
import os
from pathlib import Path
from subprocess import run
from typing import Generator
__all__ = [
"capture",
"get_video_metadata",
"get_dir_layout",
]
[docs]def capture(command, cwd=None, command_input=None):
p = run(command, cwd=cwd, input=command_input, capture_output=True, text=True)
out, err = p.stdout, p.stderr
return out, err, p.returncode
[docs]def get_dir_layout(dirpath: Path) -> Generator[str, None, None]:
"""Get list of paths relative to dirpath of all files in dir and subdirs recursively."""
for p in dirpath.iterdir():
if p.is_dir():
yield from get_dir_layout(p)
continue
yield str(p.relative_to(dirpath))