index song genres (#513)
* add song genres to search index * reset all song genre metadata * update changelog and docs
This commit is contained in:
@@ -9,6 +9,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
- Show song artist in playout detail
|
||||
- Include song artist and cover art in channel guide (xmltv)
|
||||
- Use subtitles to display errors, which fixes many edge cases of unescaped characters
|
||||
- Properly split song genre tags
|
||||
|
||||
### Added
|
||||
- Add song genres to search index
|
||||
|
||||
### Changed
|
||||
- Randomly place song cover art on left or right side of screen
|
||||
|
||||
@@ -248,8 +248,7 @@ namespace ErsatzTV.Core.Metadata
|
||||
|
||||
if (tags.TryGetValue(MetadataFormatTag.Genre, out string genre))
|
||||
{
|
||||
// TODO: split genres? or is this only ever one?
|
||||
result.Genres.Add(new Genre { Name = genre });
|
||||
result.Genres.AddRange(SplitGenres(genre).Map(n => new Genre { Name = n }));
|
||||
}
|
||||
|
||||
if (tags.TryGetValue(MetadataFormatTag.Title, out string title))
|
||||
@@ -1140,5 +1139,17 @@ namespace ErsatzTV.Core.Metadata
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static IEnumerable<string> SplitGenres(string genre)
|
||||
{
|
||||
char[] delimiters = new[] { '/', '|', ';', '\\' }
|
||||
.Filter(d => genre.IndexOf(d, StringComparison.OrdinalIgnoreCase) != -1)
|
||||
.DefaultIfEmpty(',')
|
||||
.ToArray();
|
||||
|
||||
return genre.Split(delimiters, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Where(i => !string.IsNullOrWhiteSpace(i))
|
||||
.Select(i => i.Trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +103,8 @@ namespace ErsatzTV.Infrastructure.Data.Repositories
|
||||
.ThenInclude(mm => mm.Streams)
|
||||
.Include(mi => (mi as Song).SongMetadata)
|
||||
.ThenInclude(mm => mm.Tags)
|
||||
.Include(mi => (mi as Song).SongMetadata)
|
||||
.ThenInclude(mm => mm.Genres)
|
||||
.Include(mi => (mi as Song).MediaVersions)
|
||||
.ThenInclude(mm => mm.Streams)
|
||||
.Include(mi => mi.TraktListItems)
|
||||
|
||||
+3843
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,33 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ErsatzTV.Infrastructure.Migrations
|
||||
{
|
||||
public partial class Reset_SongMetadataGenres : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql(@"DELETE FROM Genre WHERE SongMetadataId IS NOT NULL");
|
||||
|
||||
migrationBuilder.Sql(
|
||||
@"UPDATE LibraryPath SET LastScan = '0001-01-01 00:00:00' WHERE Id IN
|
||||
(SELECT LP.Id FROM LibraryPath LP INNER JOIN Library L on L.Id = LP.LibraryId WHERE MediaKind = 5)");
|
||||
|
||||
migrationBuilder.Sql(
|
||||
@"UPDATE Library SET LastScan = '0001-01-01 00:00:00' WHERE MediaKind = 5");
|
||||
|
||||
migrationBuilder.Sql(
|
||||
@"UPDATE SongMetadata SET DateUpdated = '0001-01-01 00:00:00'");
|
||||
|
||||
migrationBuilder.Sql(
|
||||
@"UPDATE LibraryFolder SET Etag = NULL WHERE Id IN
|
||||
(SELECT LF.Id FROM LibraryFolder LF INNER JOIN LibraryPath LP on LF.LibraryPathId = LP.Id INNER JOIN Library L on LP.LibraryId = L.Id WHERE MediaKind = 5)");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -867,6 +867,11 @@ namespace ErsatzTV.Infrastructure.Search
|
||||
doc.Add(new TextField(TagField, tag.Name, Field.Store.NO));
|
||||
}
|
||||
|
||||
foreach (Genre genre in metadata.Genres)
|
||||
{
|
||||
doc.Add(new TextField(GenreField, genre.Name, Field.Store.NO));
|
||||
}
|
||||
|
||||
_writer.UpdateDocument(new Term(IdField, song.Id.ToString()), doc);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -97,6 +97,7 @@ The following fields are available for searching songs:
|
||||
- `title`: The song title, or the filename of the song (without extension)
|
||||
- `album`: The song album
|
||||
- `artist`: The song artist
|
||||
- `genre`: The song genre
|
||||
- `tag`: All of the song's parent folders
|
||||
- `minutes`: the rounded-up whole number duration of the song in minutes
|
||||
- `type`: Always `song`
|
||||
|
||||
Reference in New Issue
Block a user