- Updated AGENTS.md to reflect changes in CLI commands and module organization, including the addition of an enrichment step and new functional modules. - Introduced analysis.json, identities.json, inventory.csv, and plan.json to support enriched metadata and execution planning. - Added CODE_IMPROVEMENTS.md to document identified code issues and proposed solutions for future enhancements. - Updated README.md to include new enrichment features and configuration options. - Removed unused dependency on ffmpeg-python from pyproject.toml. These changes improve the overall functionality and maintainability of the Video Library Manager project.
25 lines
775 B
Python
25 lines
775 B
Python
"""Shared utilities for Video Library Manager."""
|
|
|
|
from datetime import datetime, timezone
|
|
|
|
|
|
def utc_now() -> datetime:
|
|
"""Return current UTC time (timezone-aware)."""
|
|
return datetime.now(timezone.utc)
|
|
|
|
|
|
def ensure_utc(dt: datetime) -> datetime:
|
|
"""Ensure datetime is timezone-aware UTC (for backward compatibility with naive ISO strings)."""
|
|
if dt.tzinfo is None:
|
|
return dt.replace(tzinfo=timezone.utc)
|
|
return dt.astimezone(timezone.utc)
|
|
|
|
|
|
def format_size(size_bytes: int) -> str:
|
|
"""Format file size in human-readable format (e.g. 1.5 GB, 234.2 MB)."""
|
|
for unit in ["B", "KB", "MB", "GB", "TB"]:
|
|
if size_bytes < 1024.0:
|
|
return f"{size_bytes:.1f} {unit}"
|
|
size_bytes /= 1024.0
|
|
return f"{size_bytes:.1f} PB"
|