From ab2f1af620a0d23a111137b037c8d975a1a87add Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Fri, 23 Jan 2026 19:13:39 +0100 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20de=20l'affichage=20des=20ar?= =?UTF-8?q?tistes=20et=20correction=20des=20parent=5Fid=20dans=20les=20lis?= =?UTF-8?q?tes=20de=20lecture?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cette mise à jour corrige l'affichage des artistes dans les pistes musicales en évitant les duplications avec le nom de la station. Elle ajuste également les identifiants parents des éléments dans les listes de lecture pour une meilleure organisation hiérarchique. Les modifications affectent les fichiers playlist.rs et source.rs. --- pmoradiofrance/src/playlist.rs | 30 +++++++++++++++++++++------- pmoradiofrance/src/source.rs | 36 ++++++++++++++++++++++------------ 2 files changed, 47 insertions(+), 19 deletions(-) diff --git a/pmoradiofrance/src/playlist.rs b/pmoradiofrance/src/playlist.rs index 9a01d1d7..9ae4e30a 100644 --- a/pmoradiofrance/src/playlist.rs +++ b/pmoradiofrance/src/playlist.rs @@ -417,13 +417,26 @@ impl StationPlaylist { if let Some(ref song) = now.song { // Radio musicale avec morceau let title = now.first_line.title_or_default().to_string(); - let artist = if song.interpreters.is_empty() { + let song_artist = if song.interpreters.is_empty() { None } else { Some(song.artists_display()) }; + + // Artist affiché = "Station - Artiste du morceau" pour identifier la radio + // Éviter la duplication si l'artiste est égal au nom de la station + let artist = if let Some(ref art) = song_artist { + if art != &station.name && art != station.display_name() { + Some(format!("{} - {}", station.display_name(), art)) + } else { + Some(station.display_name().to_string()) + } + } else { + Some(station.display_name().to_string()) + }; + let album = song.release.title.clone(); - let creator = artist.clone(); + let creator = song_artist; // Creator reste l'artiste du morceau pour compatibilité let genre = Some("Music".to_string()); let class = "object.item.audioItem.musicTrack".to_string(); @@ -448,11 +461,14 @@ impl StationPlaylist { }; // Artist/Creator = "{Station} - {Subtitle}" - let artist = if !second.is_empty() { - Some(format!("{} - {}", station.name, second)) - } else { - Some(station.name.clone()) - }; + // Éviter la duplication si subtitle == nom de la station + let artist = + if !second.is_empty() && second != station.name && second != station.display_name() + { + Some(format!("{} - {}", station.name, second)) + } else { + Some(station.name.clone()) + }; let creator = artist.clone(); // Album = nom de l'émission principale let album = if !first.is_empty() { diff --git a/pmoradiofrance/src/source.rs b/pmoradiofrance/src/source.rs index 78fefeaa..0880af77 100644 --- a/pmoradiofrance/src/source.rs +++ b/pmoradiofrance/src/source.rs @@ -488,17 +488,26 @@ impl MusicSource for RadioFranceSource { .ok_or_else(|| MusicSourceError::ObjectNotFound(id.to_string()))?; // Build items for this group only (main + webradios) - let mut items = vec![self + let group_id = format!("radiofrance:group:{}", slug); + + let mut main_item = self .build_station_item(&group.main) .await - .map_err(|e| MusicSourceError::BrowseError(e.to_string()))?]; + .map_err(|e| MusicSourceError::BrowseError(e.to_string()))?; + + // Fix parent_id to point to the group container + main_item.parent_id = group_id.clone(); + let mut items = vec![main_item]; for webradio in &group.webradios { - items.push( - self.build_station_item(webradio) - .await - .map_err(|e| MusicSourceError::BrowseError(e.to_string()))?, - ); + let mut item = self + .build_station_item(webradio) + .await + .map_err(|e| MusicSourceError::BrowseError(e.to_string()))?; + + // Fix parent_id to point to the group container + item.parent_id = group_id.clone(); + items.push(item); } Ok(BrowseResult::Items(items)) @@ -514,11 +523,14 @@ impl MusicSource for RadioFranceSource { // Build items for local radios only let mut items = Vec::new(); for station in &groups.local_radios { - items.push( - self.build_station_item(station) - .await - .map_err(|e| MusicSourceError::BrowseError(e.to_string()))?, - ); + let mut item = self + .build_station_item(station) + .await + .map_err(|e| MusicSourceError::BrowseError(e.to_string()))?; + + // Fix parent_id to point to the ICI container + item.parent_id = "radiofrance:ici".to_string(); + items.push(item); } Ok(BrowseResult::Items(items))