Trailer.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. public Trailer()
  16. {
  17. RemoteTrailers = new List<MediaUrl>();
  18. Taglines = new List<string>();
  19. SoundtrackIds = new List<Guid>();
  20. LocalTrailerIds = new List<Guid>();
  21. Tags = new List<string>();
  22. }
  23. public List<Guid> LocalTrailerIds { get; set; }
  24. public List<MediaUrl> RemoteTrailers { get; set; }
  25. /// <summary>
  26. /// Gets or sets the tags.
  27. /// </summary>
  28. /// <value>The tags.</value>
  29. public List<string> Tags { get; set; }
  30. /// <summary>
  31. /// Gets or sets the taglines.
  32. /// </summary>
  33. /// <value>The taglines.</value>
  34. public List<string> Taglines { get; set; }
  35. /// <summary>
  36. /// Gets or sets the budget.
  37. /// </summary>
  38. /// <value>The budget.</value>
  39. public double? Budget { get; set; }
  40. /// <summary>
  41. /// Gets or sets the revenue.
  42. /// </summary>
  43. /// <value>The revenue.</value>
  44. public double? Revenue { get; set; }
  45. /// <summary>
  46. /// Gets or sets the critic rating.
  47. /// </summary>
  48. /// <value>The critic rating.</value>
  49. public float? CriticRating { get; set; }
  50. /// <summary>
  51. /// Gets or sets the critic rating summary.
  52. /// </summary>
  53. /// <value>The critic rating summary.</value>
  54. public string CriticRatingSummary { get; set; }
  55. /// <summary>
  56. /// Gets a value indicating whether this instance is local trailer.
  57. /// </summary>
  58. /// <value><c>true</c> if this instance is local trailer; otherwise, <c>false</c>.</value>
  59. [IgnoreDataMember]
  60. public bool IsLocalTrailer
  61. {
  62. get
  63. {
  64. // Local trailers are not part of children
  65. return Parent == null;
  66. }
  67. }
  68. /// <summary>
  69. /// Should be overridden to return the proper folder where metadata lives
  70. /// </summary>
  71. /// <value>The meta location.</value>
  72. [IgnoreDataMember]
  73. public override string MetaLocation
  74. {
  75. get
  76. {
  77. if (!IsLocalTrailer)
  78. {
  79. return System.IO.Path.GetDirectoryName(Path);
  80. }
  81. return base.MetaLocation;
  82. }
  83. }
  84. /// <summary>
  85. /// Needed because the resolver stops at the trailer folder and we find the video inside.
  86. /// </summary>
  87. /// <value><c>true</c> if [use parent path to create resolve args]; otherwise, <c>false</c>.</value>
  88. protected override bool UseParentPathToCreateResolveArgs
  89. {
  90. get { return !IsLocalTrailer; }
  91. }
  92. public override string GetUserDataKey()
  93. {
  94. var key = this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Tvdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? this.GetProviderId(MetadataProviders.Tvcom);
  95. if (!string.IsNullOrWhiteSpace(key))
  96. {
  97. return key + "-trailer";
  98. }
  99. return base.GetUserDataKey();
  100. }
  101. protected override bool GetBlockUnratedValue(UserConfiguration config)
  102. {
  103. return config.BlockUnratedTrailers;
  104. }
  105. }
  106. }