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,
|
video_id TEXT PRIMARY KEY,
|
||||||
title TEXT,
|
title TEXT,
|
||||||
channel TEXT,
|
channel TEXT,
|
||||||
|
published TEXT,
|
||||||
symlink TEXT,
|
symlink TEXT,
|
||||||
status TEXT,
|
status TEXT,
|
||||||
is_live BOOLEAN DEFAULT 0,
|
is_live BOOLEAN DEFAULT 0,
|
||||||
|
|
@ -69,6 +70,17 @@ def init_db():
|
||||||
channel_name TEXT PRIMARY KEY
|
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()
|
conn.commit()
|
||||||
|
|
||||||
# Retry loop for DB initialization to prevent crash on SMB lock
|
# Retry loop for DB initialization to prevent crash on SMB lock
|
||||||
|
|
@ -147,6 +159,12 @@ def tlog(msg):
|
||||||
if len(transcode_log_buffer) > 500:
|
if len(transcode_log_buffer) > 500:
|
||||||
transcode_log_buffer.pop(0)
|
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():
|
def detect_encoder():
|
||||||
"""Detect best available hardware encoder."""
|
"""Detect best available hardware encoder."""
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
@ -552,9 +570,12 @@ def scan_for_unindexed_videos():
|
||||||
"lost": []
|
"lost": []
|
||||||
}
|
}
|
||||||
|
|
||||||
# Helper to check if file is video
|
results = {
|
||||||
def is_video(f):
|
"unindexed": [],
|
||||||
return f.suffix.lower() in ['.mp4', '.mkv', '.webm', '.mov']
|
"redundant": [],
|
||||||
|
"rescue": [],
|
||||||
|
"lost": []
|
||||||
|
}
|
||||||
|
|
||||||
# --- Scan SOURCE_DIR (Standard Orphan Check) ---
|
# --- Scan SOURCE_DIR (Standard Orphan Check) ---
|
||||||
if SOURCE_DIR.exists():
|
if SOURCE_DIR.exists():
|
||||||
|
|
@ -815,7 +836,14 @@ def process_videos():
|
||||||
if not channel_path.is_dir():
|
if not channel_path.is_dir():
|
||||||
continue
|
continue
|
||||||
for video_file in channel_path.glob("*.*"):
|
for video_file in channel_path.glob("*.*"):
|
||||||
video_id = video_file.stem
|
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
|
# Lookup in local map
|
||||||
meta = video_map.get(video_id)
|
meta = video_map.get(video_id)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue