debug de la playlist history de radio paradise
This commit is contained in:
@@ -341,13 +341,6 @@ fn spawn_playlist_event_handler(manager: Arc<ParadiseChannelManager>) {
|
|||||||
e
|
e
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if let Err(e) = append_track_to_history(descriptor, &cache_pk).await {
|
|
||||||
tracing::warn!(
|
|
||||||
"Failed to update history for channel {}: {}",
|
|
||||||
descriptor.display_name,
|
|
||||||
e
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -361,22 +354,3 @@ fn channel_from_live_playlist(playlist_id: &str) -> Option<&'static ChannelDescr
|
|||||||
.iter()
|
.iter()
|
||||||
.find(|descriptor| descriptor.slug == slug)
|
.find(|descriptor| descriptor.slug == slug)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn append_track_to_history(descriptor: &ChannelDescriptor, cache_pk: &str) -> Result<()> {
|
|
||||||
let playlist_id = format!("radio-paradise-history-{}", descriptor.slug);
|
|
||||||
let manager = pmoplaylist::PlaylistManager();
|
|
||||||
let handle = manager
|
|
||||||
.get_persistent_write_handle(playlist_id.clone())
|
|
||||||
.await
|
|
||||||
.with_context(|| format!("Failed to get history playlist {}", playlist_id))?;
|
|
||||||
|
|
||||||
if handle.contains_pk(cache_pk).await? {
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
handle
|
|
||||||
.push(cache_pk.to_string())
|
|
||||||
.await
|
|
||||||
.with_context(|| format!("Failed to append {} to {}", cache_pk, playlist_id))?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -272,14 +272,25 @@ impl RadioParadisePlaylistFeeder {
|
|||||||
// 5. Sauvegarder les métadonnées
|
// 5. Sauvegarder les métadonnées
|
||||||
self.save_metadata(&pk, song, &block).await?;
|
self.save_metadata(&pk, song, &block).await?;
|
||||||
|
|
||||||
// 6. Calculer le TTL
|
// 6. Vérifier si la chanson est déjà dans la playlist
|
||||||
|
if self.playlist_handle.contains_pk(&pk).await? {
|
||||||
|
tracing::debug!(
|
||||||
|
"RadioParadisePlaylistFeeder: Skipping duplicate song {} - {} (pk={})",
|
||||||
|
idx,
|
||||||
|
song.title,
|
||||||
|
pk
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 7. Calculer le TTL
|
||||||
let sched_end = song
|
let sched_end = song
|
||||||
.sched_end_time_ms()
|
.sched_end_time_ms()
|
||||||
.ok_or_else(|| anyhow::anyhow!("Cannot calculate TTL without sched_time_millis"))?;
|
.ok_or_else(|| anyhow::anyhow!("Cannot calculate TTL without sched_time_millis"))?;
|
||||||
let ttl_ms = sched_end.saturating_sub(now_ms);
|
let ttl_ms = sched_end.saturating_sub(now_ms);
|
||||||
let ttl = Duration::from_millis(ttl_ms);
|
let ttl = Duration::from_millis(ttl_ms);
|
||||||
|
|
||||||
// 7. Push dans la playlist avec TTL
|
// 8. Push dans la playlist avec TTL
|
||||||
self.playlist_handle.push_with_ttl(pk.clone(), ttl).await?;
|
self.playlist_handle.push_with_ttl(pk.clone(), ttl).await?;
|
||||||
|
|
||||||
tracing::info!(
|
tracing::info!(
|
||||||
|
|||||||
Reference in New Issue
Block a user