2
0

UserItemData.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #pragma warning disable CS1591
  2. using System;
  3. using System.Text.Json.Serialization;
  4. namespace MediaBrowser.Controller.Entities
  5. {
  6. /// <summary>
  7. /// Class UserItemData.
  8. /// </summary>
  9. public class UserItemData
  10. {
  11. /// <summary>
  12. /// Gets or sets the user id.
  13. /// </summary>
  14. /// <value>The user id.</value>
  15. public Guid UserId { get; set; }
  16. /// <summary>
  17. /// Gets or sets the key.
  18. /// </summary>
  19. /// <value>The key.</value>
  20. public string Key { get; set; }
  21. /// <summary>
  22. /// The _rating.
  23. /// </summary>
  24. private double? _rating;
  25. /// <summary>
  26. /// Gets or sets the users 0-10 rating.
  27. /// </summary>
  28. /// <value>The rating.</value>
  29. /// <exception cref="ArgumentOutOfRangeException">Rating;A 0 to 10 rating is required for UserItemData.</exception>
  30. public double? Rating
  31. {
  32. get => _rating;
  33. set
  34. {
  35. if (value.HasValue)
  36. {
  37. if (value.Value < 0 || value.Value > 10)
  38. {
  39. throw new ArgumentOutOfRangeException(nameof(value), "A 0 to 10 rating is required for UserItemData.");
  40. }
  41. }
  42. _rating = value;
  43. }
  44. }
  45. /// <summary>
  46. /// Gets or sets the playback position ticks.
  47. /// </summary>
  48. /// <value>The playback position ticks.</value>
  49. public long PlaybackPositionTicks { get; set; }
  50. /// <summary>
  51. /// Gets or sets the play count.
  52. /// </summary>
  53. /// <value>The play count.</value>
  54. public int PlayCount { get; set; }
  55. /// <summary>
  56. /// Gets or sets a value indicating whether this instance is favorite.
  57. /// </summary>
  58. /// <value><c>true</c> if this instance is favorite; otherwise, <c>false</c>.</value>
  59. public bool IsFavorite { get; set; }
  60. /// <summary>
  61. /// Gets or sets the last played date.
  62. /// </summary>
  63. /// <value>The last played date.</value>
  64. public DateTime? LastPlayedDate { get; set; }
  65. /// <summary>
  66. /// Gets or sets a value indicating whether this <see cref="UserItemData" /> is played.
  67. /// </summary>
  68. /// <value><c>true</c> if played; otherwise, <c>false</c>.</value>
  69. public bool Played { get; set; }
  70. /// <summary>
  71. /// Gets or sets the index of the audio stream.
  72. /// </summary>
  73. /// <value>The index of the audio stream.</value>
  74. public int? AudioStreamIndex { get; set; }
  75. /// <summary>
  76. /// Gets or sets the index of the subtitle stream.
  77. /// </summary>
  78. /// <value>The index of the subtitle stream.</value>
  79. public int? SubtitleStreamIndex { get; set; }
  80. public const double MinLikeValue = 6.5;
  81. /// <summary>
  82. /// This is an interpreted property to indicate likes or dislikes
  83. /// This should never be serialized.
  84. /// </summary>
  85. /// <value><c>null</c> if [likes] contains no value, <c>true</c> if [likes]; otherwise, <c>false</c>.</value>
  86. [JsonIgnore]
  87. public bool? Likes
  88. {
  89. get
  90. {
  91. if (Rating != null)
  92. {
  93. return Rating >= MinLikeValue;
  94. }
  95. return null;
  96. }
  97. set
  98. {
  99. if (value.HasValue)
  100. {
  101. Rating = value.Value ? 10 : 1;
  102. }
  103. else
  104. {
  105. Rating = null;
  106. }
  107. }
  108. }
  109. }
  110. }