From 962180f53e22db9c3a710428dc0abf7b5cbb26e0 Mon Sep 17 00:00:00 2001 From: Jason Dove <1695733+jasongdove@users.noreply.github.com> Date: Sun, 2 Nov 2025 09:25:22 -0600 Subject: [PATCH] fix indexing songs with null artists/album artists --- CHANGELOG.md | 1 + ErsatzTV.Application/MediaCards/Mapper.cs | 2 +- ErsatzTV.Infrastructure/Search/ElasticSearchIndex.cs | 3 +++ ErsatzTV.Infrastructure/Search/LuceneSearchIndex.cs | 7 ++++--- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4cf0aaa8..0faf0746c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix building sequential schedules across a UTC offset change - Fix block start time calculation across a UTC offset change - Fix XMLTV generation for channels using on-demand playout mode +- Fix some removed songs from appearing in the trash ### Changed - Use smaller batch size for search index updates (100, down from 1000) diff --git a/ErsatzTV.Application/MediaCards/Mapper.cs b/ErsatzTV.Application/MediaCards/Mapper.cs index 326a4b23d..ffe46c8b1 100644 --- a/ErsatzTV.Application/MediaCards/Mapper.cs +++ b/ErsatzTV.Application/MediaCards/Mapper.cs @@ -140,7 +140,7 @@ internal static class Mapper return new SongCardViewModel( songMetadata.SongId, songMetadata.Title, - string.Join(", ", songMetadata.Artists) + album, + string.Join(", ", songMetadata.Artists ?? []) + album, songMetadata.SortTitle, GetThumbnail(songMetadata, None, None), songMetadata.Song.State); diff --git a/ErsatzTV.Infrastructure/Search/ElasticSearchIndex.cs b/ErsatzTV.Infrastructure/Search/ElasticSearchIndex.cs index c988fc355..c63ed0083 100644 --- a/ErsatzTV.Infrastructure/Search/ElasticSearchIndex.cs +++ b/ErsatzTV.Infrastructure/Search/ElasticSearchIndex.cs @@ -730,6 +730,9 @@ public class ElasticSearchIndex : ISearchIndex { try { + metadata.AlbumArtists ??= []; + metadata.Artists ??= []; + var doc = new ElasticSearchItem { Id = song.Id, diff --git a/ErsatzTV.Infrastructure/Search/LuceneSearchIndex.cs b/ErsatzTV.Infrastructure/Search/LuceneSearchIndex.cs index 405984392..5e7547fa5 100644 --- a/ErsatzTV.Infrastructure/Search/LuceneSearchIndex.cs +++ b/ErsatzTV.Infrastructure/Search/LuceneSearchIndex.cs @@ -1287,12 +1287,13 @@ public sealed class LuceneSearchIndex : ISearchIndex private async Task UpdateSong(ISearchRepository searchRepository, Song song) { Option maybeMetadata = song.SongMetadata.HeadOrNone(); - if (maybeMetadata.IsSome) + foreach (var metadata in maybeMetadata) { - SongMetadata metadata = maybeMetadata.ValueUnsafe(); - try { + metadata.AlbumArtists ??= []; + metadata.Artists ??= []; + var doc = new Document { new StringField(IdField, song.Id.ToString(CultureInfo.InvariantCulture), Field.Store.YES),