Trailer.cs 3.9 KB

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