123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- #pragma warning disable CS1591
- using System;
- using System.Text.Json.Serialization;
- namespace MediaBrowser.Controller.Entities
- {
- /// <summary>
- /// Class UserItemData.
- /// </summary>
- public class UserItemData
- {
- public const double MinLikeValue = 6.5;
- /// <summary>
- /// The _rating.
- /// </summary>
- private double? _rating;
- /// <summary>
- /// Gets or sets the key.
- /// </summary>
- /// <value>The key.</value>
- public required string Key { get; set; }
- /// <summary>
- /// Gets or sets the users 0-10 rating.
- /// </summary>
- /// <value>The rating.</value>
- /// <exception cref="ArgumentOutOfRangeException">Rating;A 0 to 10 rating is required for UserItemData.</exception>
- public double? Rating
- {
- get => _rating;
- set
- {
- if (value.HasValue)
- {
- if (value.Value < 0 || value.Value > 10)
- {
- throw new ArgumentOutOfRangeException(nameof(value), "A 0 to 10 rating is required for UserItemData.");
- }
- }
- _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; }
- /// <summary>
- /// Gets or sets the index of the audio stream.
- /// </summary>
- /// <value>The index of the audio stream.</value>
- public int? AudioStreamIndex { get; set; }
- /// <summary>
- /// Gets or sets the index of the subtitle stream.
- /// </summary>
- /// <value>The index of the subtitle stream.</value>
- public int? SubtitleStreamIndex { get; set; }
- /// <summary>
- /// Gets or sets a value indicating whether the item is liked or not.
- /// 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>
- [JsonIgnore]
- public bool? Likes
- {
- get
- {
- if (Rating is not null)
- {
- return Rating >= MinLikeValue;
- }
- return null;
- }
- set
- {
- if (value.HasValue)
- {
- Rating = value.Value ? 10 : 1;
- }
- else
- {
- Rating = null;
- }
- }
- }
- }
- }
|