mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-14 06:12:17 +01:00
added a new MusicGenre entity
This commit is contained in:
@@ -634,6 +634,17 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
return GetItemByName<Genre>(ConfigurationManager.ApplicationPaths.GenrePath, name, CancellationToken.None, allowSlowProviders);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the genre.
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
||||
/// <returns>Task{MusicGenre}.</returns>
|
||||
public Task<MusicGenre> GetMusicGenre(string name, bool allowSlowProviders = false)
|
||||
{
|
||||
return GetItemByName<MusicGenre>(ConfigurationManager.ApplicationPaths.MusicGenrePath, name, CancellationToken.None, allowSlowProviders);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a Genre
|
||||
/// </summary>
|
||||
|
||||
@@ -111,6 +111,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
var items = inputItems.Where(i => !(i is MusicArtist)).ToList();
|
||||
|
||||
// Add search hints based on item name
|
||||
hints.AddRange(items.Select(item =>
|
||||
{
|
||||
var index = GetIndex(item.Name, searchTerm, terms);
|
||||
@@ -144,8 +145,9 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
}
|
||||
}
|
||||
|
||||
// Find genres
|
||||
var genres = items.SelectMany(i => i.Genres)
|
||||
// Find genres, from non-audio items
|
||||
var genres = items.Where(i => !(i is Audio) && !(i is MusicAlbum) && !(i is MusicAlbumDisc) && !(i is MusicArtist) && !(i is MusicVideo))
|
||||
.SelectMany(i => i.Genres)
|
||||
.Where(i => !string.IsNullOrEmpty(i))
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
@@ -169,6 +171,32 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
}
|
||||
}
|
||||
|
||||
// Find music genres
|
||||
var musicGenres = items.Where(i => (i is Audio) || (i is MusicAlbum) || (i is MusicAlbumDisc) || (i is MusicArtist) || (i is MusicVideo))
|
||||
.SelectMany(i => i.Genres)
|
||||
.Where(i => !string.IsNullOrEmpty(i))
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
|
||||
foreach (var item in musicGenres)
|
||||
{
|
||||
var index = GetIndex(item, searchTerm, terms);
|
||||
|
||||
if (index.Item2 != -1)
|
||||
{
|
||||
try
|
||||
{
|
||||
var genre = await _libraryManager.GetMusicGenre(item).ConfigureAwait(false);
|
||||
|
||||
hints.Add(new Tuple<BaseItem, string, int>(genre, index.Item1, index.Item2));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error getting {0}", ex, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Find studios
|
||||
var studios = items.SelectMany(i => i.Studios)
|
||||
.Where(i => !string.IsNullOrEmpty(i))
|
||||
|
||||
@@ -106,6 +106,18 @@ namespace MediaBrowser.Server.Implementations
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path to the Genre directory
|
||||
/// </summary>
|
||||
/// <value>The genre path.</value>
|
||||
public string MusicGenrePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(ItemsByNamePath, "MusicGenre");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path to the Studio directory
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user