mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-04 06:48:35 +01:00
de-normalize item by name data. create counts during library scan for fast access.
This commit is contained in:
@@ -1,11 +1,20 @@
|
||||
|
||||
using MediaBrowser.Model.Dto;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities.Audio
|
||||
{
|
||||
/// <summary>
|
||||
/// Class Artist
|
||||
/// </summary>
|
||||
public class Artist : BaseItem, IItemByName
|
||||
public class Artist : BaseItem, IItemByName, IHasMusicGenres
|
||||
{
|
||||
public Artist()
|
||||
{
|
||||
ItemCounts = new ItemByNameCounts();
|
||||
UserItemCounts = new Dictionary<Guid, ItemByNameCounts>();
|
||||
}
|
||||
|
||||
public string LastFmImageUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -17,5 +26,8 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||
return "Artist-" + Name;
|
||||
}
|
||||
|
||||
public ItemByNameCounts ItemCounts { get; set; }
|
||||
|
||||
public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||
/// <summary>
|
||||
/// Class Audio
|
||||
/// </summary>
|
||||
public class Audio : BaseItem, IHasMediaStreams, IHasAlbumArtist
|
||||
public class Audio : BaseItem, IHasMediaStreams, IHasAlbumArtist, IHasArtist, IHasMusicGenres
|
||||
{
|
||||
public Audio()
|
||||
{
|
||||
|
||||
@@ -5,4 +5,9 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||
{
|
||||
string AlbumArtist { get; }
|
||||
}
|
||||
|
||||
public interface IHasArtist
|
||||
{
|
||||
bool HasArtist(string name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities.Audio
|
||||
{
|
||||
public interface IHasMusicGenres
|
||||
{
|
||||
List<string> Genres { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities.Audio
|
||||
@@ -6,10 +7,15 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||
/// <summary>
|
||||
/// Class MusicAlbum
|
||||
/// </summary>
|
||||
public class MusicAlbum : Folder, IHasAlbumArtist
|
||||
public class MusicAlbum : Folder, IHasAlbumArtist, IHasArtist, IHasMusicGenres
|
||||
{
|
||||
public MusicAlbum()
|
||||
{
|
||||
Artists = new string[] { };
|
||||
}
|
||||
|
||||
public string LastFmImageUrl { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Songs will group into us so don't also include us in the index
|
||||
/// </summary>
|
||||
@@ -60,23 +66,17 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||
/// <returns><c>true</c> if the specified artist has artist; otherwise, <c>false</c>.</returns>
|
||||
public bool HasArtist(string artist)
|
||||
{
|
||||
return RecursiveChildren.OfType<Audio>().Any(i => i.HasArtist(artist));
|
||||
return string.Equals(AlbumArtist, artist, StringComparison.OrdinalIgnoreCase)
|
||||
|| Artists.Contains(artist, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public string AlbumArtist
|
||||
{
|
||||
get
|
||||
{
|
||||
return RecursiveChildren
|
||||
.OfType<Audio>()
|
||||
.Select(i => i.AlbumArtist)
|
||||
.FirstOrDefault(i => !string.IsNullOrEmpty(i));
|
||||
}
|
||||
}
|
||||
public string AlbumArtist { get; set; }
|
||||
|
||||
public string[] Artists { get; set; }
|
||||
}
|
||||
|
||||
public class MusicAlbumDisc : Folder
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
|
||||
using MediaBrowser.Model.Dto;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities.Audio
|
||||
{
|
||||
/// <summary>
|
||||
@@ -6,6 +9,12 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||
/// </summary>
|
||||
public class MusicGenre : BaseItem, IItemByName
|
||||
{
|
||||
public MusicGenre()
|
||||
{
|
||||
ItemCounts = new ItemByNameCounts();
|
||||
UserItemCounts = new Dictionary<Guid, ItemByNameCounts>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user data key.
|
||||
/// </summary>
|
||||
@@ -14,5 +23,9 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||
{
|
||||
return "MusicGenre-" + Name;
|
||||
}
|
||||
|
||||
public ItemByNameCounts ItemCounts { get; set; }
|
||||
|
||||
public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user