Trailer.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using MediaBrowser.Model.Configuration;
  2. using MediaBrowser.Model.Entities;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Runtime.Serialization;
  6. namespace MediaBrowser.Controller.Entities
  7. {
  8. /// <summary>
  9. /// Class Trailer
  10. /// </summary>
  11. public class Trailer : Video, IHasCriticRating, IHasSoundtracks, IHasBudget, IHasTrailers, IHasKeywords, IHasTaglines, IHasTags, IHasPreferredMetadataLanguage, IHasMetascore
  12. {
  13. public List<Guid> SoundtrackIds { get; set; }
  14. public string PreferredMetadataLanguage { get; set; }
  15. /// <summary>
  16. /// Gets or sets the preferred metadata country code.
  17. /// </summary>
  18. /// <value>The preferred metadata country code.</value>
  19. public string PreferredMetadataCountryCode { get; set; }
  20. public Trailer()
  21. {
  22. RemoteTrailers = new List<MediaUrl>();
  23. Taglines = new List<string>();
  24. SoundtrackIds = new List<Guid>();
  25. LocalTrailerIds = new List<Guid>();
  26. Tags = new List<string>();
  27. Keywords = new List<string>();
  28. }
  29. public float? Metascore { get; set; }
  30. public List<Guid> LocalTrailerIds { get; set; }
  31. public List<MediaUrl> RemoteTrailers { get; set; }
  32. public List<string> Keywords { get; set; }
  33. /// <summary>
  34. /// Gets or sets the tags.
  35. /// </summary>
  36. /// <value>The tags.</value>
  37. public List<string> Tags { get; set; }
  38. /// <summary>
  39. /// Gets or sets the taglines.
  40. /// </summary>
  41. /// <value>The taglines.</value>
  42. public List<string> Taglines { get; set; }
  43. /// <summary>
  44. /// Gets or sets the budget.
  45. /// </summary>
  46. /// <value>The budget.</value>
  47. public double? Budget { get; set; }
  48. /// <summary>
  49. /// Gets or sets the revenue.
  50. /// </summary>
  51. /// <value>The revenue.</value>
  52. public double? Revenue { get; set; }
  53. /// <summary>
  54. /// Gets or sets the critic rating.
  55. /// </summary>
  56. /// <value>The critic rating.</value>
  57. public float? CriticRating { get; set; }
  58. /// <summary>
  59. /// Gets or sets the critic rating summary.
  60. /// </summary>
  61. /// <value>The critic rating summary.</value>
  62. public string CriticRatingSummary { get; set; }
  63. /// <summary>
  64. /// Gets a value indicating whether this instance is local trailer.
  65. /// </summary>
  66. /// <value><c>true</c> if this instance is local trailer; otherwise, <c>false</c>.</value>
  67. [IgnoreDataMember]
  68. public bool IsLocalTrailer
  69. {
  70. get
  71. {
  72. // Local trailers are not part of children
  73. return Parent == null;
  74. }
  75. }
  76. /// <summary>
  77. /// Should be overridden to return the proper folder where metadata lives
  78. /// </summary>
  79. /// <value>The meta location.</value>
  80. [IgnoreDataMember]
  81. public override string MetaLocation
  82. {
  83. get
  84. {
  85. if (!IsLocalTrailer)
  86. {
  87. return System.IO.Path.GetDirectoryName(Path);
  88. }
  89. return base.MetaLocation;
  90. }
  91. }
  92. /// <summary>
  93. /// Needed because the resolver stops at the trailer folder and we find the video inside.
  94. /// </summary>
  95. /// <value><c>true</c> if [use parent path to create resolve args]; otherwise, <c>false</c>.</value>
  96. protected override bool UseParentPathToCreateResolveArgs
  97. {
  98. get { return !IsLocalTrailer; }
  99. }
  100. public override string GetUserDataKey()
  101. {
  102. var key = this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Tvdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? this.GetProviderId(MetadataProviders.Tvcom);
  103. if (!string.IsNullOrWhiteSpace(key))
  104. {
  105. return key + "-trailer";
  106. }
  107. return base.GetUserDataKey();
  108. }
  109. protected override bool GetBlockUnratedValue(UserConfiguration config)
  110. {
  111. return config.BlockUnratedTrailers;
  112. }
  113. }
  114. }