Changement du mécanisme d'attention sur les channels Radio Paradise.

This commit is contained in:
2025-11-29 14:19:16 +01:00
parent cf3f0afde4
commit 0a03f72467
44 changed files with 564 additions and 231 deletions

View File

@@ -222,7 +222,12 @@ impl ReadHandle {
let resource = meta.to_didl_resource(url).await;
// Récupérer les métadonnées pour construire l'Item DIDL
let title = meta.get_title().await.ok().flatten().unwrap_or_else(|| "Unknown".to_string());
let title = meta
.get_title()
.await
.ok()
.flatten()
.unwrap_or_else(|| "Unknown".to_string());
let artist = meta.get_artist().await.ok().flatten();
let album = meta.get_album().await.ok().flatten();
let genre = meta.get_genre().await.ok().flatten();

View File

@@ -222,6 +222,16 @@ impl WriteHandle {
Ok(())
}
/// Vérifie si la playlist contient déjà un pk
pub async fn contains_pk(&self, cache_pk: &str) -> Result<bool> {
if !self.playlist.is_alive() {
return Err(crate::Error::PlaylistDeleted(self.playlist.id.clone()));
}
let core = self.playlist.core.read().await;
Ok(core.tracks.iter().any(|record| record.cache_pk == cache_pk))
}
/// Change le TTL par défaut
pub async fn set_default_ttl(&self, ttl: Option<Duration>) -> Result<()> {
if !self.playlist.is_alive() {

View File

@@ -47,13 +47,13 @@
mod error;
mod handle;
mod manager;
mod persistence;
mod playlist;
mod track;
#[cfg(feature = "pmoserver")]
mod sse;
#[cfg(feature = "pmoserver")]
pub mod openapi;
mod persistence;
mod playlist;
#[cfg(feature = "pmoserver")]
mod sse;
mod track;
#[cfg(feature = "pmoconfig")]
mod config_ext;
@@ -62,10 +62,10 @@ mod config_ext;
pub use error::{Error, Result};
pub use handle::{ReadHandle, WriteHandle};
pub use manager::{register_audio_cache, PlaylistManager, PlaylistManager as Manager};
pub use manager::{PlaylistEvent, PlaylistEventEnvelope, PlaylistEventKind, subscribe_events};
pub use track::PlaylistTrack;
pub use manager::{subscribe_events, PlaylistEvent, PlaylistEventEnvelope, PlaylistEventKind};
#[cfg(feature = "pmoserver")]
pub use sse::playlist_events_router;
pub use track::PlaylistTrack;
#[cfg(feature = "pmoconfig")]
pub use config_ext::PlaylistConfigExt;

View File

@@ -5,15 +5,18 @@ use crate::persistence::PersistenceManager;
use crate::playlist::core::PlaylistConfig;
use crate::playlist::Playlist;
use crate::Result;
use pmocache::{CacheBroadcastEvent, CacheSubscription};
use once_cell::sync::OnceCell;
use pmocache::{CacheBroadcastEvent, CacheSubscription};
use std::collections::HashMap;
use std::path::PathBuf;
use std::sync::{Arc, atomic::{AtomicU64, Ordering}};
use std::time::Duration;
use tokio::sync::RwLock;
use tokio::sync::broadcast;
use std::sync::RwLock as StdRwLock;
use std::sync::{
atomic::{AtomicU64, Ordering},
Arc,
};
use std::time::Duration;
use tokio::sync::broadcast;
use tokio::sync::RwLock;
/// Singleton PlaylistManager
static PLAYLIST_MANAGER: OnceCell<PlaylistManager> = OnceCell::new();
@@ -181,14 +184,16 @@ impl PlaylistManager {
/// Notifie tous les callbacks qu'une playlist a changé.
pub(crate) fn notify_playlist_changed(&self, id: &str) {
self.notify_playlist_event(
id,
PlaylistEventKind::Updated,
);
self.notify_playlist_event(id, PlaylistEventKind::Updated);
}
/// Notifie les callbacks qu'un morceau a été joué pour une playlist donnée.
pub(crate) fn notify_playlist_track_played(&self, playlist_id: &str, cache_pk: &str, qualifier: &str) {
pub(crate) fn notify_playlist_track_played(
&self,
playlist_id: &str,
cache_pk: &str,
qualifier: &str,
) {
self.notify_playlist_event(
playlist_id,
PlaylistEventKind::TrackPlayed {

View File

@@ -3,14 +3,14 @@
//! Route type : `GET /api/playlists/events?playlist_id=foo`
use crate::{subscribe_events, PlaylistEventKind};
#[cfg(feature = "pmoserver")]
use async_stream::stream;
use axum::{
extract::Query,
response::sse::{Event, KeepAlive, Sse},
response::IntoResponse,
Router,
};
#[cfg(feature = "pmoserver")]
use async_stream::stream;
use serde::{Deserialize, Serialize};
#[cfg(feature = "pmoserver")]
use tokio_stream::StreamExt;