Trailer.cs 3.2 KB

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