feat(videos): add manual Convert button per MOV file on Pi
- New POST /api/local-video/convert route triggers queue_convert(force=True) - queue_convert() now returns True/False/None and accepts force param to bypass the auto-convert toggle (manual always works) - Convert button shown for non-MP4, non-converting files in video list - Clicking spins the button and refreshes list after 1s to show badge Co-authored-by: Copilot <[email protected]>
This commit is contained in:
@@ -25,20 +25,21 @@ def is_convert_enabled():
|
||||
return app_sql.get_setting(CONVERT_SETTING, "0") == "1"
|
||||
|
||||
|
||||
def queue_convert(relative_path):
|
||||
"""Spawn a background greenlet to re-encode relative_path to web-ready MP4.
|
||||
No-op if conversion is disabled, already running, or file is already MP4."""
|
||||
if not is_convert_enabled():
|
||||
return
|
||||
def queue_convert(relative_path, force=False):
|
||||
"""Spawn a background thread to re-encode relative_path to web-ready MP4.
|
||||
Returns True if queued, False if already converting, None if skipped (disabled/MP4).
|
||||
Set force=True to bypass the is_convert_enabled() check (manual trigger)."""
|
||||
if not force and not is_convert_enabled():
|
||||
return None
|
||||
if relative_path.lower().endswith(".mp4"):
|
||||
return
|
||||
return None
|
||||
with _converting_lock:
|
||||
if relative_path in _converting:
|
||||
return
|
||||
return False
|
||||
_converting.add(relative_path)
|
||||
gevent.sleep(0) # yield before spawning thread
|
||||
t = threading.Thread(target=_convert_bg, args=(relative_path,), daemon=True)
|
||||
t.start()
|
||||
return True
|
||||
|
||||
|
||||
def _convert_bg(relative_path):
|
||||
|
||||
Reference in New Issue
Block a user