Add automatic skip detection for playlist playback
Background poller monitors HA media_player state during playlist sessions. When a track transition occurs and the previous track was played < 40% of its duration, automatically records "skip" feedback. Also includes the previously uncommitted delete_feedback endpoint. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,8 @@ from haunt_fm.config import settings
|
||||
from haunt_fm.services.embedding import is_model_loaded
|
||||
from haunt_fm.services.embedding_worker import is_running as is_worker_running
|
||||
from haunt_fm.services.embedding_worker import last_processed as worker_last_processed
|
||||
from haunt_fm.services.skip_detector import get_sessions as get_skip_sessions
|
||||
from haunt_fm.services.skip_detector import is_running as is_skip_detector_running
|
||||
|
||||
router = APIRouter(prefix="/api")
|
||||
|
||||
@@ -103,6 +105,25 @@ async def status(session: AsyncSession = Depends(get_session)):
|
||||
"total_generated": total_playlists,
|
||||
"last_generated": last_playlist.isoformat() if last_playlist else None,
|
||||
},
|
||||
"skip_detector": {
|
||||
"running": is_skip_detector_running(),
|
||||
"active_sessions": len(get_skip_sessions()),
|
||||
"sessions": [
|
||||
{
|
||||
"speaker_entity": entity,
|
||||
"playlist_id": s.playlist_id,
|
||||
"current_position": s.current_position,
|
||||
"total_tracks": len(s.tracks),
|
||||
"current_track": (
|
||||
f"{s.tracks[s.current_position]['artist']} - {s.tracks[s.current_position]['title']}"
|
||||
if s.current_position < len(s.tracks)
|
||||
else None
|
||||
),
|
||||
"last_activity": s.last_activity_at.isoformat(),
|
||||
}
|
||||
for entity, s in get_skip_sessions().items()
|
||||
],
|
||||
},
|
||||
},
|
||||
"dependencies": {
|
||||
"lastfm_api": "configured" if settings.lastfm_api_key else "not_configured",
|
||||
|
||||
Reference in New Issue
Block a user