Trailer.cs 1.9 KB

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