Trailer.cs 3.7 KB

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