fix: robust ID matching and DB migrations for vanished symlinks
All checks were successful
Docker Build / build (push) Successful in 13s
All checks were successful
Docker Build / build (push) Successful in 13s
This commit is contained in:
parent
04c7c5ec5e
commit
581de707d7
1 changed files with 32 additions and 4 deletions
|
|
@ -55,6 +55,7 @@ def init_db():
|
|||
video_id TEXT PRIMARY KEY,
|
||||
title TEXT,
|
||||
channel TEXT,
|
||||
published TEXT,
|
||||
symlink TEXT,
|
||||
status TEXT,
|
||||
is_live BOOLEAN DEFAULT 0,
|
||||
|
|
@ -69,6 +70,17 @@ def init_db():
|
|||
channel_name TEXT PRIMARY KEY
|
||||
);
|
||||
""")
|
||||
|
||||
# Migration: Add is_live if it doesn't exist
|
||||
try:
|
||||
conn.execute("ALTER TABLE videos ADD COLUMN is_live BOOLEAN DEFAULT 0")
|
||||
except: pass
|
||||
|
||||
# Migration: Add published if it doesn't exist
|
||||
try:
|
||||
conn.execute("ALTER TABLE videos ADD COLUMN published TEXT")
|
||||
except: pass
|
||||
|
||||
conn.commit()
|
||||
|
||||
# Retry loop for DB initialization to prevent crash on SMB lock
|
||||
|
|
@ -147,6 +159,12 @@ def tlog(msg):
|
|||
if len(transcode_log_buffer) > 500:
|
||||
transcode_log_buffer.pop(0)
|
||||
|
||||
# Helper to check if file is video
|
||||
def is_video(f):
|
||||
if isinstance(f, str):
|
||||
f = Path(f)
|
||||
return f.suffix.lower() in ['.mp4', '.mkv', '.webm', '.mov', '.avi']
|
||||
|
||||
def detect_encoder():
|
||||
"""Detect best available hardware encoder."""
|
||||
import subprocess
|
||||
|
|
@ -552,9 +570,12 @@ def scan_for_unindexed_videos():
|
|||
"lost": []
|
||||
}
|
||||
|
||||
# Helper to check if file is video
|
||||
def is_video(f):
|
||||
return f.suffix.lower() in ['.mp4', '.mkv', '.webm', '.mov']
|
||||
results = {
|
||||
"unindexed": [],
|
||||
"redundant": [],
|
||||
"rescue": [],
|
||||
"lost": []
|
||||
}
|
||||
|
||||
# --- Scan SOURCE_DIR (Standard Orphan Check) ---
|
||||
if SOURCE_DIR.exists():
|
||||
|
|
@ -815,6 +836,13 @@ def process_videos():
|
|||
if not channel_path.is_dir():
|
||||
continue
|
||||
for video_file in channel_path.glob("*.*"):
|
||||
if not is_video(video_file):
|
||||
continue
|
||||
|
||||
# Robust ID Extraction
|
||||
video_id = extract_id_from_filename(video_file.name)
|
||||
if not video_id:
|
||||
# Fallback for old simple-name format
|
||||
video_id = video_file.stem
|
||||
|
||||
# Lookup in local map
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue