Trailer.cs 2.5 KB

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