Trailer.cs 3.0 KB

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