Trailer.cs 2.6 KB

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