Trailer.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. using MediaBrowser.Controller.Providers;
  2. using MediaBrowser.Model.Configuration;
  3. using MediaBrowser.Model.Entities;
  4. using System.Collections.Generic;
  5. using System.Runtime.Serialization;
  6. using MediaBrowser.Model.Providers;
  7. namespace MediaBrowser.Controller.Entities
  8. {
  9. /// <summary>
  10. /// Class Trailer
  11. /// </summary>
  12. public class Trailer : Video, IHasCriticRating, IHasProductionLocations, IHasBudget, IHasTaglines, IHasMetascore, IHasOriginalTitle, IHasLookupInfo<TrailerInfo>
  13. {
  14. public List<string> ProductionLocations { get; set; }
  15. public Trailer()
  16. {
  17. RemoteTrailers = new List<MediaUrl>();
  18. Taglines = new List<string>();
  19. Keywords = new List<string>();
  20. ProductionLocations = new List<string>();
  21. TrailerTypes = new List<TrailerType> { TrailerType.LocalTrailer };
  22. }
  23. public List<TrailerType> TrailerTypes { get; set; }
  24. public float? Metascore { get; set; }
  25. public List<MediaUrl> RemoteTrailers { get; set; }
  26. [IgnoreDataMember]
  27. public bool IsLocalTrailer
  28. {
  29. get { return TrailerTypes.Contains(TrailerType.LocalTrailer); }
  30. }
  31. /// <summary>
  32. /// Gets or sets the taglines.
  33. /// </summary>
  34. /// <value>The taglines.</value>
  35. public List<string> Taglines { get; set; }
  36. /// <summary>
  37. /// Gets or sets the budget.
  38. /// </summary>
  39. /// <value>The budget.</value>
  40. public double? Budget { get; set; }
  41. /// <summary>
  42. /// Gets or sets the revenue.
  43. /// </summary>
  44. /// <value>The revenue.</value>
  45. public double? Revenue { get; set; }
  46. public override UnratedItem GetBlockUnratedType()
  47. {
  48. return UnratedItem.Trailer;
  49. }
  50. public TrailerInfo GetLookupInfo()
  51. {
  52. var info = GetItemLookupInfo<TrailerInfo>();
  53. info.IsLocalTrailer = TrailerTypes.Contains(TrailerType.LocalTrailer);
  54. if (!IsInMixedFolder)
  55. {
  56. info.Name = System.IO.Path.GetFileName(ContainingFolderPath);
  57. }
  58. return info;
  59. }
  60. public override bool BeforeMetadataRefresh()
  61. {
  62. var hasChanges = base.BeforeMetadataRefresh();
  63. if (!ProductionYear.HasValue)
  64. {
  65. var info = LibraryManager.ParseName(Name);
  66. var yearInName = info.Year;
  67. if (yearInName.HasValue)
  68. {
  69. ProductionYear = yearInName;
  70. hasChanges = true;
  71. }
  72. else
  73. {
  74. // Try to get the year from the folder name
  75. if (!IsInMixedFolder)
  76. {
  77. info = LibraryManager.ParseName(System.IO.Path.GetFileName(ContainingFolderPath));
  78. yearInName = info.Year;
  79. if (yearInName.HasValue)
  80. {
  81. ProductionYear = yearInName;
  82. hasChanges = true;
  83. }
  84. }
  85. }
  86. }
  87. return hasChanges;
  88. }
  89. public override List<ExternalUrl> GetRelatedUrls()
  90. {
  91. var list = base.GetRelatedUrls();
  92. var imdbId = this.GetProviderId(MetadataProviders.Imdb);
  93. if (!string.IsNullOrWhiteSpace(imdbId))
  94. {
  95. list.Add(new ExternalUrl
  96. {
  97. Name = "Trakt",
  98. Url = string.Format("https://trakt.tv/movies/{0}", imdbId)
  99. });
  100. }
  101. return list;
  102. }
  103. [IgnoreDataMember]
  104. public override bool StopRefreshIfLocalMetadataFound
  105. {
  106. get
  107. {
  108. // Need people id's from internet metadata
  109. return false;
  110. }
  111. }
  112. }
  113. }