mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-08 10:44:23 -04:00
Added filters to the item list page
This commit is contained in:
parent
a0834c5710
commit
1fcf696bd5
@ -48,7 +48,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
/// What to sort the results by
|
/// What to sort the results by
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The sort by.</value>
|
/// <value>The sort by.</value>
|
||||||
[ApiMember(Name = "SortBy", Description = "Optional. Specify one or more sort orders, comma delimeted. Options: Album, AlbumArtist, Artist, CommunityRating, DateCreated, DatePlayed, PremiereDate, ProductionYear, SortName, Random, Runtime", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
[ApiMember(Name = "SortBy", Description = "Optional. Specify one or more sort orders, comma delimeted. Options: Album, AlbumArtist, Artist, CommunityRating, DateCreated, DatePlayed, PlayCount, PremiereDate, ProductionYear, SortName, Random, Runtime", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||||
public string SortBy { get; set; }
|
public string SortBy { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -243,6 +243,22 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
{
|
{
|
||||||
switch (filter)
|
switch (filter)
|
||||||
{
|
{
|
||||||
|
case ItemFilter.Likes:
|
||||||
|
return items.Where(item =>
|
||||||
|
{
|
||||||
|
var userdata = item.GetUserData(user, false);
|
||||||
|
|
||||||
|
return userdata != null && userdata.Likes.HasValue && userdata.Likes.Value;
|
||||||
|
});
|
||||||
|
|
||||||
|
case ItemFilter.Dislikes:
|
||||||
|
return items.Where(item =>
|
||||||
|
{
|
||||||
|
var userdata = item.GetUserData(user, false);
|
||||||
|
|
||||||
|
return userdata != null && userdata.Likes.HasValue && !userdata.Likes.Value;
|
||||||
|
});
|
||||||
|
|
||||||
case ItemFilter.IsFavorite:
|
case ItemFilter.IsFavorite:
|
||||||
return items.Where(item =>
|
return items.Where(item =>
|
||||||
{
|
{
|
||||||
|
@ -33,6 +33,14 @@ namespace MediaBrowser.Model.Querying
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The item is resumable
|
/// The item is resumable
|
||||||
/// </summary>
|
/// </summary>
|
||||||
IsResumable = 7
|
IsResumable = 7,
|
||||||
|
/// <summary>
|
||||||
|
/// The likes
|
||||||
|
/// </summary>
|
||||||
|
Likes = 8,
|
||||||
|
/// <summary>
|
||||||
|
/// The dislikes
|
||||||
|
/// </summary>
|
||||||
|
Dislikes = 9
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,5 +50,9 @@ namespace MediaBrowser.Model.Querying
|
|||||||
/// The production year
|
/// The production year
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string ProductionYear = "ProductionYear";
|
public const string ProductionYear = "ProductionYear";
|
||||||
|
/// <summary>
|
||||||
|
/// The play count
|
||||||
|
/// </summary>
|
||||||
|
public const string PlayCount = "PlayCount";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,6 +163,7 @@
|
|||||||
<Compile Include="Sorting\CommunityRatingComparer.cs" />
|
<Compile Include="Sorting\CommunityRatingComparer.cs" />
|
||||||
<Compile Include="Sorting\DateCreatedComparer.cs" />
|
<Compile Include="Sorting\DateCreatedComparer.cs" />
|
||||||
<Compile Include="Sorting\DatePlayedComparer.cs" />
|
<Compile Include="Sorting\DatePlayedComparer.cs" />
|
||||||
|
<Compile Include="Sorting\PlayCountComparer.cs" />
|
||||||
<Compile Include="Sorting\PremiereDateComparer.cs" />
|
<Compile Include="Sorting\PremiereDateComparer.cs" />
|
||||||
<Compile Include="Sorting\ProductionYearComparer.cs" />
|
<Compile Include="Sorting\ProductionYearComparer.cs" />
|
||||||
<Compile Include="Sorting\RandomComparer.cs" />
|
<Compile Include="Sorting\RandomComparer.cs" />
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
using MediaBrowser.Controller.Entities;
|
||||||
|
using MediaBrowser.Controller.Sorting;
|
||||||
|
using MediaBrowser.Model.Querying;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Server.Implementations.Sorting
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class PlayCountComparer
|
||||||
|
/// </summary>
|
||||||
|
public class PlayCountComparer : IUserBaseItemComparer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the user.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The user.</value>
|
||||||
|
public User User { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Compares the specified x.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x">The x.</param>
|
||||||
|
/// <param name="y">The y.</param>
|
||||||
|
/// <returns>System.Int32.</returns>
|
||||||
|
public int Compare(BaseItem x, BaseItem y)
|
||||||
|
{
|
||||||
|
return GetValue(x).CompareTo(GetValue(y));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the date.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x">The x.</param>
|
||||||
|
/// <returns>DateTime.</returns>
|
||||||
|
private int GetValue(BaseItem x)
|
||||||
|
{
|
||||||
|
var userdata = x.GetUserData(User, false);
|
||||||
|
|
||||||
|
return userdata == null ? 0 : userdata.PlayCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the name.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The name.</value>
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return ItemSortBy.PlayCount; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user