mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-04 14:58:36 +01:00
calculate item by name counts on the fly
This commit is contained in:
@@ -66,6 +66,24 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||
/// <value>The artist.</value>
|
||||
public List<string> Artists { get; set; }
|
||||
|
||||
[IgnoreDataMember]
|
||||
public List<string> AllArtists
|
||||
{
|
||||
get
|
||||
{
|
||||
var list = new List<string>();
|
||||
|
||||
if (!string.IsNullOrEmpty(AlbumArtist))
|
||||
{
|
||||
list.Add(AlbumArtist);
|
||||
}
|
||||
list.AddRange(Artists);
|
||||
|
||||
return list;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the album.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
using MediaBrowser.Common.Progress;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -17,9 +15,6 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||
/// </summary>
|
||||
public class MusicArtist : Folder, IMetadataContainer, IItemByName, IHasMusicGenres, IHasDualAccess, IHasTags, IHasProductionLocations, IHasLookupInfo<ArtistInfo>
|
||||
{
|
||||
[IgnoreDataMember]
|
||||
public List<ItemByNameCounts> UserItemCountList { get; set; }
|
||||
|
||||
public bool IsAccessedByName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -65,7 +60,6 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||
|
||||
public MusicArtist()
|
||||
{
|
||||
UserItemCountList = new List<ItemByNameCounts>();
|
||||
Tags = new List<string>();
|
||||
ProductionLocations = new List<string>();
|
||||
}
|
||||
@@ -230,5 +224,10 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems)
|
||||
{
|
||||
return inputItems.OfType<IHasArtist>().Where(i => i.HasArtist(Name)).Cast<BaseItem>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Runtime.Serialization;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities.Audio
|
||||
{
|
||||
@@ -10,11 +9,6 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||
/// </summary>
|
||||
public class MusicGenre : BaseItem, IItemByName
|
||||
{
|
||||
public MusicGenre()
|
||||
{
|
||||
UserItemCountList = new List<ItemByNameCounts>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user data key.
|
||||
/// </summary>
|
||||
@@ -24,9 +18,6 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||
return "MusicGenre-" + Name;
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
public List<ItemByNameCounts> UserItemCountList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the folder containing the item.
|
||||
/// If the item is a folder, it returns the folder itself
|
||||
@@ -51,5 +42,10 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems)
|
||||
{
|
||||
return inputItems.Where(i => (i is IHasMusicGenres) && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
using MediaBrowser.Model.Dto;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
public class GameGenre : BaseItem, IItemByName
|
||||
{
|
||||
public GameGenre()
|
||||
{
|
||||
UserItemCountList = new List<ItemByNameCounts>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user data key.
|
||||
/// </summary>
|
||||
@@ -20,9 +15,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
return "GameGenre-" + Name;
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
public List<ItemByNameCounts> UserItemCountList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the folder containing the item.
|
||||
/// If the item is a folder, it returns the folder itself
|
||||
@@ -47,5 +39,10 @@ namespace MediaBrowser.Controller.Entities
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems)
|
||||
{
|
||||
return inputItems.Where(i => (i is Game) && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Controller.Entities.Audio;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
@@ -9,11 +10,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// </summary>
|
||||
public class Genre : BaseItem, IItemByName
|
||||
{
|
||||
public Genre()
|
||||
{
|
||||
UserItemCountList = new List<ItemByNameCounts>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user data key.
|
||||
/// </summary>
|
||||
@@ -23,9 +19,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
return "Genre-" + Name;
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
public List<ItemByNameCounts> UserItemCountList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the folder containing the item.
|
||||
/// If the item is a folder, it returns the folder itself
|
||||
@@ -50,5 +43,10 @@ namespace MediaBrowser.Controller.Entities
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems)
|
||||
{
|
||||
return inputItems.Where(i => !(i is Game) && !(i is IHasMusicGenres) && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using MediaBrowser.Model.Dto;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
@@ -10,37 +7,16 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// </summary>
|
||||
public interface IItemByName
|
||||
{
|
||||
List<ItemByNameCounts> UserItemCountList { get; set; }
|
||||
/// <summary>
|
||||
/// Gets the tagged items.
|
||||
/// </summary>
|
||||
/// <param name="inputItems">The input items.</param>
|
||||
/// <returns>IEnumerable{BaseItem}.</returns>
|
||||
IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems);
|
||||
}
|
||||
|
||||
public interface IHasDualAccess : IItemByName
|
||||
{
|
||||
bool IsAccessedByName { get; }
|
||||
}
|
||||
|
||||
public static class ItemByNameExtensions
|
||||
{
|
||||
public static ItemByNameCounts GetItemByNameCounts(this IItemByName item, Guid userId)
|
||||
{
|
||||
if (userId == Guid.Empty)
|
||||
{
|
||||
throw new ArgumentNullException("userId");
|
||||
}
|
||||
|
||||
return item.UserItemCountList.FirstOrDefault(i => i.UserId == userId);
|
||||
}
|
||||
|
||||
public static void SetItemByNameCounts(this IItemByName item, Guid userId, ItemByNameCounts counts)
|
||||
{
|
||||
var current = item.UserItemCountList.FirstOrDefault(i => i.UserId == userId);
|
||||
|
||||
if (current != null)
|
||||
{
|
||||
item.UserItemCountList.Remove(current);
|
||||
}
|
||||
|
||||
counts.UserId = userId;
|
||||
item.UserItemCountList.Add(counts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
@@ -10,19 +10,11 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// </summary>
|
||||
public class Person : BaseItem, IItemByName, IHasLookupInfo<PersonLookupInfo>
|
||||
{
|
||||
public Person()
|
||||
{
|
||||
UserItemCountList = new List<ItemByNameCounts>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the place of birth.
|
||||
/// </summary>
|
||||
/// <value>The place of birth.</value>
|
||||
public string PlaceOfBirth { get; set; }
|
||||
|
||||
[IgnoreDataMember]
|
||||
public List<ItemByNameCounts> UserItemCountList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user data key.
|
||||
@@ -62,6 +54,11 @@ namespace MediaBrowser.Controller.Entities
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems)
|
||||
{
|
||||
return inputItems.Where(i => i.People.Any(p => string.Equals(p.Name, Name, StringComparison.OrdinalIgnoreCase)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Runtime.Serialization;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
@@ -10,11 +9,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// </summary>
|
||||
public class Studio : BaseItem, IItemByName
|
||||
{
|
||||
public Studio()
|
||||
{
|
||||
UserItemCountList = new List<ItemByNameCounts>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user data key.
|
||||
/// </summary>
|
||||
@@ -24,9 +18,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
return "Studio-" + Name;
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
public List<ItemByNameCounts> UserItemCountList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the folder containing the item.
|
||||
/// If the item is a folder, it returns the folder itself
|
||||
@@ -51,5 +42,10 @@ namespace MediaBrowser.Controller.Entities
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems)
|
||||
{
|
||||
return inputItems.Where(i => i.Studios.Contains(Name, StringComparer.OrdinalIgnoreCase));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Runtime.Serialization;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
@@ -10,14 +9,6 @@ namespace MediaBrowser.Controller.Entities
|
||||
/// </summary>
|
||||
public class Year : BaseItem, IItemByName
|
||||
{
|
||||
public Year()
|
||||
{
|
||||
UserItemCountList = new List<ItemByNameCounts>();
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
public List<ItemByNameCounts> UserItemCountList { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user data key.
|
||||
/// </summary>
|
||||
@@ -51,5 +42,19 @@ namespace MediaBrowser.Controller.Entities
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems)
|
||||
{
|
||||
int year;
|
||||
|
||||
var usCulture = new CultureInfo("en-US");
|
||||
|
||||
if (!int.TryParse(Name, NumberStyles.Integer, usCulture, out year))
|
||||
{
|
||||
return inputItems;
|
||||
}
|
||||
|
||||
return inputItems.Where(i => i.ProductionYear.HasValue && i.ProductionYear.Value == year);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user