Trailer.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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, IHasTaglines, IHasTags, IHasPreferredMetadataLanguage
  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. }
  28. public List<Guid> LocalTrailerIds { get; set; }
  29. public List<MediaUrl> RemoteTrailers { get; set; }
  30. /// <summary>
  31. /// Gets or sets the tags.
  32. /// </summary>
  33. /// <value>The tags.</value>
  34. public List<string> Tags { 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. /// <summary>
  74. /// Should be overridden to return the proper folder where metadata lives
  75. /// </summary>
  76. /// <value>The meta location.</value>
  77. [IgnoreDataMember]
  78. public override string MetaLocation
  79. {
  80. get
  81. {
  82. if (!IsLocalTrailer)
  83. {
  84. return System.IO.Path.GetDirectoryName(Path);
  85. }
  86. return base.MetaLocation;
  87. }
  88. }
  89. /// <summary>
  90. /// Needed because the resolver stops at the trailer folder and we find the video inside.
  91. /// </summary>
  92. /// <value><c>true</c> if [use parent path to create resolve args]; otherwise, <c>false</c>.</value>
  93. protected override bool UseParentPathToCreateResolveArgs
  94. {
  95. get { return !IsLocalTrailer; }
  96. }
  97. public override string GetUserDataKey()
  98. {
  99. var key = this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Tvdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? this.GetProviderId(MetadataProviders.Tvcom);
  100. if (!string.IsNullOrWhiteSpace(key))
  101. {
  102. return key + "-trailer";
  103. }
  104. return base.GetUserDataKey();
  105. }
  106. protected override bool GetBlockUnratedValue(UserConfiguration config)
  107. {
  108. return config.BlockUnratedTrailers;
  109. }
  110. }
  111. }