Trailer.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. using MediaBrowser.Controller.Providers;
  2. using MediaBrowser.Model.Configuration;
  3. using MediaBrowser.Model.Entities;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Globalization;
  7. using System.Linq;
  8. using System.Runtime.Serialization;
  9. namespace MediaBrowser.Controller.Entities
  10. {
  11. /// <summary>
  12. /// Class Trailer
  13. /// </summary>
  14. public class Trailer : Video, IHasCriticRating, IHasSoundtracks, IHasBudget, IHasTrailers, IHasKeywords, IHasTaglines, IHasPreferredMetadataLanguage, IHasMetascore, IHasLookupInfo<TrailerInfo>
  15. {
  16. public List<Guid> SoundtrackIds { get; set; }
  17. public string PreferredMetadataLanguage { get; set; }
  18. /// <summary>
  19. /// Gets or sets the preferred metadata country code.
  20. /// </summary>
  21. /// <value>The preferred metadata country code.</value>
  22. public string PreferredMetadataCountryCode { get; set; }
  23. public Trailer()
  24. {
  25. RemoteTrailers = new List<MediaUrl>();
  26. Taglines = new List<string>();
  27. SoundtrackIds = new List<Guid>();
  28. LocalTrailerIds = new List<Guid>();
  29. Keywords = new List<string>();
  30. }
  31. public float? Metascore { get; set; }
  32. public List<Guid> LocalTrailerIds { get; set; }
  33. public List<MediaUrl> RemoteTrailers { get; set; }
  34. public List<string> Keywords { get; set; }
  35. /// <summary>
  36. /// Gets or sets the taglines.
  37. /// </summary>
  38. /// <value>The taglines.</value>
  39. public List<string> Taglines { get; set; }
  40. /// <summary>
  41. /// Gets or sets the budget.
  42. /// </summary>
  43. /// <value>The budget.</value>
  44. public double? Budget { get; set; }
  45. /// <summary>
  46. /// Gets or sets the revenue.
  47. /// </summary>
  48. /// <value>The revenue.</value>
  49. public double? Revenue { get; set; }
  50. /// <summary>
  51. /// Gets or sets the critic rating.
  52. /// </summary>
  53. /// <value>The critic rating.</value>
  54. public float? CriticRating { get; set; }
  55. /// <summary>
  56. /// Gets or sets the critic rating summary.
  57. /// </summary>
  58. /// <value>The critic rating summary.</value>
  59. public string CriticRatingSummary { get; set; }
  60. /// <summary>
  61. /// Gets a value indicating whether this instance is local trailer.
  62. /// </summary>
  63. /// <value><c>true</c> if this instance is local trailer; otherwise, <c>false</c>.</value>
  64. [IgnoreDataMember]
  65. public bool IsLocalTrailer
  66. {
  67. get
  68. {
  69. // Local trailers are not part of children
  70. return Parent == null;
  71. }
  72. }
  73. public override string GetUserDataKey()
  74. {
  75. var key = this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Tvdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? this.GetProviderId(MetadataProviders.Tvcom);
  76. if (!string.IsNullOrWhiteSpace(key))
  77. {
  78. key = key + "-trailer";
  79. // Make sure different trailers have their own data.
  80. if (RunTimeTicks.HasValue)
  81. {
  82. key += "-" + RunTimeTicks.Value.ToString(CultureInfo.InvariantCulture);
  83. }
  84. return key;
  85. }
  86. return base.GetUserDataKey();
  87. }
  88. protected override bool GetBlockUnratedValue(UserConfiguration config)
  89. {
  90. return config.BlockUnratedItems.Contains(UnratedItem.Trailer);
  91. }
  92. public TrailerInfo GetLookupInfo()
  93. {
  94. var info = GetItemLookupInfo<TrailerInfo>();
  95. info.IsLocalTrailer = IsLocalTrailer;
  96. return info;
  97. }
  98. }
  99. }