This commit is contained in:
2026-01-11 00:52:54 -08:00
parent 6eb02f22b5
commit 7c1959483f
6 changed files with 51 additions and 32 deletions

View File

@@ -11,11 +11,12 @@ try:
import ffmpeg # type: ignore
except Exception:
ffmpeg = None # type: ignore
import os
import base64
import logging
import time
from pathlib import Path
from typing import Any, Iterable
from typing import Any, Iterable, Optional
from datetime import datetime
from dataclasses import dataclass, field
from fnmatch import fnmatch
@@ -32,6 +33,14 @@ CHUNK_SIZE = 1024 * 1024 # 1 MiB
_format_logger = logging.getLogger(__name__)
def expand_path(p: str | Path | None) -> Path:
"""Expand ~ and environment variables in path."""
if p is None:
return None # type: ignore
expanded = os.path.expandvars(str(p))
return Path(expanded).expanduser()
def ensure_directory(path: Path) -> None:
"""Ensure *path* exists as a directory."""
try: