mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-24 11:05:08 +01:00
Added some favorites api calls
This commit is contained in:
parent
fd9ba20451
commit
c1c4c85fc2
@@ -145,7 +145,7 @@ namespace MediaBrowser.Model.DTO
|
||||
/// User data for this item based on the user it's being requested for
|
||||
/// </summary>
|
||||
[ProtoMember(40)]
|
||||
public UserItemData UserData { get; set; }
|
||||
public DTOUserItemData UserData { get; set; }
|
||||
|
||||
[ProtoMember(41)]
|
||||
public ItemSpecialCounts SpecialCounts { get; set; }
|
||||
|
||||
23
MediaBrowser.Model/DTO/DTOUserItemData.cs
Normal file
23
MediaBrowser.Model/DTO/DTOUserItemData.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using ProtoBuf;
|
||||
|
||||
namespace MediaBrowser.Model.DTO
|
||||
{
|
||||
[ProtoContract]
|
||||
public class DTOUserItemData
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public float? Rating { get; set; }
|
||||
|
||||
[ProtoMember(2)]
|
||||
public long PlaybackPositionTicks { get; set; }
|
||||
|
||||
[ProtoMember(3)]
|
||||
public int PlayCount { get; set; }
|
||||
|
||||
[ProtoMember(4)]
|
||||
public bool IsFavorite { get; set; }
|
||||
|
||||
[ProtoMember(5)]
|
||||
public bool? Likes { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
namespace MediaBrowser.Model.DTO
|
||||
{
|
||||
/// <summary>
|
||||
/// These are the audio output formats that the api is cabaple of streaming
|
||||
/// These are the video output formats that the api is cabaple of streaming
|
||||
/// This does not limit the inputs, only the outputs.
|
||||
/// </summary>
|
||||
public enum VideoOutputFormats
|
||||
|
||||
@@ -96,6 +96,24 @@ namespace MediaBrowser.Model.Entities
|
||||
return GetParentalAllowedRecursiveChildren(user).Where(f => f.Studios != null && f.Studios.Any(s => s.Equals(studio, StringComparison.OrdinalIgnoreCase)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds all recursive items within a top-level parent that the user has marked as a favorite
|
||||
/// </summary>
|
||||
public IEnumerable<BaseItem> GetFavoriteItems(User user)
|
||||
{
|
||||
return GetParentalAllowedRecursiveChildren(user).Where(c =>
|
||||
{
|
||||
UserItemData data = c.GetUserData(user);
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
return data.IsFavorite;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds all recursive items within a top-level parent that contain the given person and are allowed for the current user
|
||||
/// </summary>
|
||||
|
||||
@@ -1,25 +1,67 @@
|
||||
using System;
|
||||
using ProtoBuf;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace MediaBrowser.Model.Entities
|
||||
{
|
||||
[ProtoContract]
|
||||
public class UserItemData
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public UserItemRating Rating { get; set; }
|
||||
private float? _Rating = null;
|
||||
/// <summary>
|
||||
/// Gets or sets the users 0-10 rating
|
||||
/// </summary>
|
||||
public float? Rating
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Rating;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.HasValue)
|
||||
{
|
||||
if (value.Value < 0 || value.Value > 10)
|
||||
{
|
||||
throw new InvalidOperationException("A 0-10 rating is required for UserItemData.");
|
||||
}
|
||||
}
|
||||
|
||||
_Rating = value;
|
||||
}
|
||||
}
|
||||
|
||||
[ProtoMember(2)]
|
||||
public long PlaybackPositionTicks { get; set; }
|
||||
|
||||
[ProtoMember(3)]
|
||||
public int PlayCount { get; set; }
|
||||
}
|
||||
|
||||
public enum UserItemRating
|
||||
{
|
||||
Likes,
|
||||
Dislikes,
|
||||
Favorite
|
||||
public bool IsFavorite { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// This is an interpreted property to indicate likes or dislikes
|
||||
/// This should never be serialized.
|
||||
/// </summary>
|
||||
[IgnoreDataMember]
|
||||
public bool? Likes
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Rating != null)
|
||||
{
|
||||
return Rating >= 6.5;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value.HasValue)
|
||||
{
|
||||
Rating = value.Value ? 10 : 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Rating = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
<Compile Include="Configuration\ServerConfiguration.cs" />
|
||||
<Compile Include="DTO\AudioInfo.cs" />
|
||||
<Compile Include="DTO\AudioOutputFormats.cs" />
|
||||
<Compile Include="DTO\DTOUserItemData.cs" />
|
||||
<Compile Include="DTO\SeriesInfo.cs" />
|
||||
<Compile Include="Authentication\AuthenticationResult.cs" />
|
||||
<Compile Include="DTO\DTOBaseItem.cs" />
|
||||
|
||||
Reference in New Issue
Block a user