simplify
This commit is contained in:
@@ -442,12 +442,6 @@ def update_transcode_result(conn: sqlite3.Connection, filepath: str, new_path: s
|
||||
conn.commit()
|
||||
|
||||
|
||||
def remove_from_cache(conn: sqlite3.Connection, filepath: str):
|
||||
"""Remove a file from the cache."""
|
||||
conn.execute("DELETE FROM files WHERE path = ?", (filepath,))
|
||||
conn.commit()
|
||||
|
||||
|
||||
def get_cache_stats(conn: sqlite3.Connection) -> dict:
|
||||
"""Get comprehensive stats from the cache."""
|
||||
# File counts and sizes
|
||||
@@ -598,24 +592,6 @@ def check_disk_space():
|
||||
log.info("")
|
||||
|
||||
|
||||
def get_video_duration(filepath: str) -> Optional[float]:
|
||||
"""Get video duration in seconds using ffprobe."""
|
||||
try:
|
||||
result = subprocess.run([
|
||||
"ffprobe", "-v", "quiet",
|
||||
"-show_entries", "format=duration",
|
||||
"-of", "json",
|
||||
filepath
|
||||
], capture_output=True, text=True, timeout=30)
|
||||
|
||||
if result.returncode == 0:
|
||||
data = json.loads(result.stdout)
|
||||
return float(data.get("format", {}).get("duration", 0))
|
||||
except Exception as e:
|
||||
log.debug(f"Failed to get duration for {filepath}: {e}")
|
||||
return None
|
||||
|
||||
|
||||
def handle_interrupt(signum, frame):
|
||||
"""Handle SIGINT/SIGTERM gracefully."""
|
||||
log.warning("=" * 50)
|
||||
@@ -675,17 +651,6 @@ def get_video_codec(filepath: str) -> Optional[str]:
|
||||
return None
|
||||
|
||||
|
||||
def is_hevc(filepath: str) -> bool:
|
||||
"""Check if a file is already HEVC encoded."""
|
||||
codec = get_video_codec(filepath)
|
||||
return codec in ["hevc", "h265"]
|
||||
|
||||
|
||||
def get_file_size_gb(filepath: str) -> float:
|
||||
"""Get file size in GB."""
|
||||
return os.path.getsize(filepath) / (1024 ** 3)
|
||||
|
||||
|
||||
def find_videos_to_transcode(conn: sqlite3.Connection) -> List[Dict]:
|
||||
"""Find all non-HEVC videos, sorted by size (biggest first). Uses cache for speed."""
|
||||
videos = []
|
||||
|
||||
Reference in New Issue
Block a user