Add live introdb key reload and recap playback markers

- reload introdb API key on setting updates
- support recap/preview markers in playback and next-episode flow
- add profile defaults for recap and preview auto-play settings
This commit is contained in:
Silo Server Migration
2026-05-24 00:14:17 -04:00
parent 04a7e8c82d
commit d41ffd4d5e
13 changed files with 191 additions and 35 deletions
+6 -1
View File
@@ -90,6 +90,7 @@ type AdminHandler struct {
BootstrapSensitiveConfigured map[string]bool
BootstrapSensitiveValues map[string]string
OnUserSessionsRevoked func(ctx context.Context, userID int)
OnServerSettingUpdated func(ctx context.Context, key, value string)
}
// NewAdminHandler creates a new AdminHandler backed by the given
@@ -1022,6 +1023,7 @@ var sensitiveSettingKeys = map[string]bool{
"recommendations.openai_api_key": true,
"recommendations.embedding_auth_token": true,
"tmdb.api_key": true,
"introdb.api_key": true,
"mdblist.api_key": true,
"watchsync.trakt.client_id": true,
"watchsync.trakt.client_secret": true,
@@ -1890,7 +1892,10 @@ func (h *AdminHandler) HandleUpdateSetting(w http.ResponseWriter, r *http.Reques
if h.EventBus != nil {
_ = h.EventBus.Publish(r.Context(), cache.ChannelAdmin,
cache.Event{Type: cache.EventSettingsChanged})
cache.Event{Type: cache.EventSettingsChanged, Payload: key})
}
if h.OnServerSettingUpdated != nil {
h.OnServerSettingUpdated(r.Context(), key, req.Value)
}
if sensitiveSettingKeys[key] {
+17 -5
View File
@@ -38,9 +38,6 @@ func (h *PlaybackHandler) maybeQueueLazyPlaybackMarkers(
if h == nil || session == nil || file == nil || file.ID <= 0 {
return
}
if hasOnlineSourcedMarkers(file) {
return
}
if file.MediaFolderID <= 0 {
return
}
@@ -87,6 +84,9 @@ func (h *PlaybackHandler) maybeQueueLazyPlaybackMarkers(
hasOnline := h.hasOnlineMarkerProviders()
shouldRunLocal := markers.ShouldRunLocal(mode)
shouldRunOnline := (mode == markers.ModeOnline || mode == markers.ModeBoth) && hasOnline
if shouldRunOnline && hasOnlineSourcedMarkers(file) {
shouldRunOnline = false
}
if shouldRunOnline {
// Online providers work for any enabled library (movies and series alike).
@@ -184,7 +184,9 @@ func (h *PlaybackHandler) runLazyPlaybackMarkers(
if wrote {
if refreshed := h.reloadPlaybackMarkerFile(ctx, file.ID); hasAnyMarker(refreshed) {
h.notifyPlaybackMarkers(ctx, sessionID, refreshed, mode)
return
if !runLocal || hasLocalDetectionMarkers(refreshed) {
return
}
}
}
}
@@ -193,7 +195,9 @@ func (h *PlaybackHandler) runLazyPlaybackMarkers(
// before falling through to the (expensive) local analyzer.
if refreshed := h.reloadPlaybackMarkerFile(ctx, file.ID); hasAnyMarker(refreshed) {
h.notifyPlaybackMarkers(ctx, sessionID, refreshed, mode)
return
if !runLocal || hasLocalDetectionMarkers(refreshed) {
return
}
}
if runLocal {
@@ -355,6 +359,14 @@ func hasAnyMarker(file *models.MediaFile) bool {
(file.PreviewStart != nil && file.PreviewEnd != nil)
}
func hasLocalDetectionMarkers(file *models.MediaFile) bool {
if file == nil {
return false
}
return (file.IntroStart != nil && file.IntroEnd != nil) ||
(file.CreditsStart != nil && file.CreditsEnd != nil)
}
// markerUpdateFromPayload adapts the generic markers.MarkerUpdatePayload to
// the scanner.MarkerUpdate shape consumed by FileRepository.UpsertMarkers.
// Kept narrow on purpose — the packages it bridges should not need to import
+4
View File
@@ -131,6 +131,7 @@ type Dependencies struct {
ChapterThumbnailQueuer catalog.ChapterThumbnailQueuer
PlaybackRealtimeHub *playback.RealtimeHub
OnUserSessionsRevoked func(ctx context.Context, userID int)
OnServerSettingUpdated func(ctx context.Context, key, value string)
// UserCollectionSync handles per-profile imported collections (TMDB /
// Trakt / MDBList) — the user-facing analogue of CollectionService.
@@ -628,6 +629,9 @@ func NewRouter(deps Dependencies) chi.Router {
if deps.OnUserSessionsRevoked != nil {
adminHandler.OnUserSessionsRevoked = deps.OnUserSessionsRevoked
}
if deps.OnServerSettingUpdated != nil {
adminHandler.OnServerSettingUpdated = deps.OnServerSettingUpdated
}
}
if deps.DB != nil {
jobRepo := adminjob.NewRepository(deps.DB)