Trailer.cs 3.6 KB

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