46 lines
1.7 KiB
Python
46 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Sweep Flow Auto-Pilot downloads into SCENEGOD assets.
|
|
|
|
~/Downloads/flowrinse/<category>/*.mp4 -> assets/backdrops/video/<category>/
|
|
Each mp4 gets a same-stem poster .jpg (frame at 1s) so the dock shows a thumb.
|
|
Idempotent: skips files already present with the same size. Run any time:
|
|
|
|
python3 scripts/flow_intake.py [--src ~/Downloads/flowrinse] [--dry]
|
|
"""
|
|
import argparse, shutil, subprocess, sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
DEST = ROOT / "assets" / "backdrops" / "video"
|
|
|
|
def main():
|
|
ap = argparse.ArgumentParser()
|
|
ap.add_argument("--src", default=str(Path.home() / "Downloads" / "flowrinse"))
|
|
ap.add_argument("--dry", action="store_true")
|
|
a = ap.parse_args()
|
|
src = Path(a.src).expanduser()
|
|
if not src.is_dir():
|
|
sys.exit(f"no such dir: {src}")
|
|
if not shutil.which("ffmpeg"):
|
|
sys.exit("ffmpeg required for poster frames")
|
|
copied = skipped = 0
|
|
for mp4 in sorted(src.rglob("*.mp4")):
|
|
cat = mp4.parent.name
|
|
out = DEST / cat / mp4.name
|
|
if out.exists() and out.stat().st_size == mp4.stat().st_size:
|
|
skipped += 1
|
|
continue
|
|
print(("DRY " if a.dry else "") + f"{mp4} -> {out}")
|
|
if a.dry:
|
|
continue
|
|
out.parent.mkdir(parents=True, exist_ok=True)
|
|
shutil.copy2(mp4, out)
|
|
jpg = out.with_suffix(".jpg")
|
|
subprocess.run(["ffmpeg", "-v", "error", "-ss", "1", "-i", str(out),
|
|
"-frames:v", "1", "-vf", "scale=320:-1", str(jpg), "-y"], check=False)
|
|
copied += 1
|
|
print(f"done: {copied} copied, {skipped} already present -> {DEST}")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|