Trailer.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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
  10. {
  11. public Trailer()
  12. {
  13. RemoteTrailers = new List<MediaUrl>();
  14. Taglines = new List<string>();
  15. }
  16. /// <summary>
  17. /// Gets a value indicating whether this instance is local trailer.
  18. /// </summary>
  19. /// <value><c>true</c> if this instance is local trailer; otherwise, <c>false</c>.</value>
  20. [IgnoreDataMember]
  21. public bool IsLocalTrailer
  22. {
  23. get
  24. {
  25. // Local trailers are not part of children
  26. return Parent == null;
  27. }
  28. }
  29. /// <summary>
  30. /// Should be overridden to return the proper folder where metadata lives
  31. /// </summary>
  32. /// <value>The meta location.</value>
  33. [IgnoreDataMember]
  34. public override string MetaLocation
  35. {
  36. get
  37. {
  38. if (!IsLocalTrailer)
  39. {
  40. return System.IO.Path.GetDirectoryName(Path);
  41. }
  42. return base.MetaLocation;
  43. }
  44. }
  45. /// <summary>
  46. /// Needed because the resolver stops at the trailer folder and we find the video inside.
  47. /// </summary>
  48. /// <value><c>true</c> if [use parent path to create resolve args]; otherwise, <c>false</c>.</value>
  49. protected override bool UseParentPathToCreateResolveArgs
  50. {
  51. get { return !IsLocalTrailer; }
  52. }
  53. public override string GetUserDataKey()
  54. {
  55. var key = this.GetProviderId(MetadataProviders.Tmdb) ?? this.GetProviderId(MetadataProviders.Tvdb) ?? this.GetProviderId(MetadataProviders.Imdb) ?? this.GetProviderId(MetadataProviders.Tvcom);
  56. if (!string.IsNullOrWhiteSpace(key))
  57. {
  58. return key + "-trailer";
  59. }
  60. return base.GetUserDataKey();
  61. }
  62. }
  63. }