search movies and music videos by language (#148)
This commit is contained in:
@@ -40,6 +40,7 @@ namespace ErsatzTV.Infrastructure.Search
|
||||
private const string JumpLetterField = "jump_letter";
|
||||
private const string ReleaseDateField = "release_date";
|
||||
private const string StudioField = "studio";
|
||||
private const string LanguageField = "language";
|
||||
|
||||
private const string MovieType = "movie";
|
||||
private const string ShowType = "show";
|
||||
@@ -52,7 +53,7 @@ namespace ErsatzTV.Infrastructure.Search
|
||||
|
||||
public SearchIndex(ILogger<SearchIndex> logger) => _logger = logger;
|
||||
|
||||
public int Version => 2;
|
||||
public int Version => 3;
|
||||
|
||||
public Task<bool> Initialize(ILocalFileSystem localFileSystem)
|
||||
{
|
||||
@@ -231,6 +232,8 @@ namespace ErsatzTV.Infrastructure.Search
|
||||
new StringField(JumpLetterField, GetJumpLetter(metadata), Field.Store.YES)
|
||||
};
|
||||
|
||||
AddLanguages(doc, movie.MediaVersions);
|
||||
|
||||
if (metadata.ReleaseDate.HasValue)
|
||||
{
|
||||
doc.Add(
|
||||
@@ -270,6 +273,20 @@ namespace ErsatzTV.Infrastructure.Search
|
||||
}
|
||||
}
|
||||
|
||||
private void AddLanguages(Document doc, List<MediaVersion> mediaVersions)
|
||||
{
|
||||
Option<MediaVersion> maybeVersion = mediaVersions.HeadOrNone();
|
||||
if (maybeVersion.IsSome)
|
||||
{
|
||||
MediaVersion version = maybeVersion.ValueUnsafe();
|
||||
foreach (string lang in version.Streams.Map(ms => ms.Language).Distinct()
|
||||
.Filter(s => !string.IsNullOrWhiteSpace(s)))
|
||||
{
|
||||
doc.Add(new StringField(LanguageField, lang, Field.Store.NO));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateShow(Show show)
|
||||
{
|
||||
Option<ShowMetadata> maybeMetadata = show.ShowMetadata.HeadOrNone();
|
||||
@@ -350,6 +367,8 @@ namespace ErsatzTV.Infrastructure.Search
|
||||
new StringField(JumpLetterField, GetJumpLetter(metadata), Field.Store.YES)
|
||||
};
|
||||
|
||||
AddLanguages(doc, musicVideo.MediaVersions);
|
||||
|
||||
if (metadata.ReleaseDate.HasValue)
|
||||
{
|
||||
doc.Add(
|
||||
|
||||
Reference in New Issue
Block a user