2021-05-06 15:39:20 -07:00
|
|
|
#nullable disable
|
|
|
|
|
2020-08-22 12:56:24 -07:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 13:01:16 -07:00
|
|
|
using System;
|
2019-10-15 08:49:49 -07:00
|
|
|
using System.Text.Json.Serialization;
|
2018-12-27 16:27:57 -07:00
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Entities
|
|
|
|
{
|
|
|
|
/// <summary>
|
2020-06-15 15:37:52 -07:00
|
|
|
/// Class UserItemData.
|
2018-12-27 16:27:57 -07:00
|
|
|
/// </summary>
|
|
|
|
public class UserItemData
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the user id.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The user id.</value>
|
|
|
|
public Guid UserId { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the key.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The key.</value>
|
|
|
|
public string Key { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
2020-06-15 15:37:52 -07:00
|
|
|
/// The _rating.
|
2018-12-27 16:27:57 -07:00
|
|
|
/// </summary>
|
|
|
|
private double? _rating;
|
2020-08-22 12:56:24 -07:00
|
|
|
|
2018-12-27 16:27:57 -07:00
|
|
|
/// <summary>
|
2020-06-15 15:37:52 -07:00
|
|
|
/// Gets or sets the users 0-10 rating.
|
2018-12-27 16:27:57 -07:00
|
|
|
/// </summary>
|
|
|
|
/// <value>The rating.</value>
|
2019-01-13 13:37:13 -07:00
|
|
|
/// <exception cref="ArgumentOutOfRangeException">Rating;A 0 to 10 rating is required for UserItemData.</exception>
|
2018-12-27 16:27:57 -07:00
|
|
|
public double? Rating
|
|
|
|
{
|
2019-01-13 13:31:14 -07:00
|
|
|
get => _rating;
|
2018-12-27 16:27:57 -07:00
|
|
|
set
|
|
|
|
{
|
|
|
|
if (value.HasValue)
|
|
|
|
{
|
|
|
|
if (value.Value < 0 || value.Value > 10)
|
|
|
|
{
|
2019-01-06 13:50:43 -07:00
|
|
|
throw new ArgumentOutOfRangeException(nameof(value), "A 0 to 10 rating is required for UserItemData.");
|
2018-12-27 16:27:57 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_rating = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the playback position ticks.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The playback position ticks.</value>
|
|
|
|
public long PlaybackPositionTicks { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the play count.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The play count.</value>
|
|
|
|
public int PlayCount { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets a value indicating whether this instance is favorite.
|
|
|
|
/// </summary>
|
|
|
|
/// <value><c>true</c> if this instance is favorite; otherwise, <c>false</c>.</value>
|
|
|
|
public bool IsFavorite { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the last played date.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The last played date.</value>
|
|
|
|
public DateTime? LastPlayedDate { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets a value indicating whether this <see cref="UserItemData" /> is played.
|
|
|
|
/// </summary>
|
|
|
|
/// <value><c>true</c> if played; otherwise, <c>false</c>.</value>
|
|
|
|
public bool Played { get; set; }
|
2020-08-22 12:56:24 -07:00
|
|
|
|
2018-12-27 16:27:57 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the index of the audio stream.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The index of the audio stream.</value>
|
|
|
|
public int? AudioStreamIndex { get; set; }
|
2020-08-22 12:56:24 -07:00
|
|
|
|
2018-12-27 16:27:57 -07:00
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the index of the subtitle stream.
|
|
|
|
/// </summary>
|
|
|
|
/// <value>The index of the subtitle stream.</value>
|
|
|
|
public int? SubtitleStreamIndex { get; set; }
|
|
|
|
|
|
|
|
public const double MinLikeValue = 6.5;
|
2019-01-07 16:27:46 -07:00
|
|
|
|
2018-12-27 16:27:57 -07:00
|
|
|
/// <summary>
|
2021-05-13 06:32:02 -07:00
|
|
|
/// Gets or sets a value indicating whether the item is liked or not.
|
2018-12-27 16:27:57 -07:00
|
|
|
/// This should never be serialized.
|
|
|
|
/// </summary>
|
|
|
|
/// <value><c>null</c> if [likes] contains no value, <c>true</c> if [likes]; otherwise, <c>false</c>.</value>
|
2019-10-15 08:49:49 -07:00
|
|
|
[JsonIgnore]
|
2018-12-27 16:27:57 -07:00
|
|
|
public bool? Likes
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
if (Rating != null)
|
|
|
|
{
|
|
|
|
return Rating >= MinLikeValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2020-06-15 14:43:52 -07:00
|
|
|
|
2018-12-27 16:27:57 -07:00
|
|
|
set
|
|
|
|
{
|
|
|
|
if (value.HasValue)
|
|
|
|
{
|
|
|
|
Rating = value.Value ? 10 : 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Rating = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|