Trailer.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using MediaBrowser.Controller.Providers;
  2. using MediaBrowser.Model.Configuration;
  3. using MediaBrowser.Model.Entities;
  4. using System.Collections.Generic;
  5. using System.Globalization;
  6. using System.Runtime.Serialization;
  7. using MediaBrowser.Controller.Entities.Movies;
  8. namespace MediaBrowser.Controller.Entities
  9. {
  10. /// <summary>
  11. /// Class Trailer
  12. /// </summary>
  13. public class Trailer : Video, IHasCriticRating, IHasProductionLocations, IHasBudget, IHasKeywords, IHasTaglines, IHasMetascore, IHasOriginalTitle, IHasLookupInfo<TrailerInfo>
  14. {
  15. public List<string> ProductionLocations { get; set; }
  16. public Trailer()
  17. {
  18. RemoteTrailers = new List<MediaUrl>();
  19. Taglines = new List<string>();
  20. Keywords = new List<string>();
  21. ProductionLocations = new List<string>();
  22. TrailerTypes = new List<TrailerType> { TrailerType.LocalTrailer };
  23. }
  24. public List<TrailerType> TrailerTypes { get; set; }
  25. public float? Metascore { get; set; }
  26. public List<MediaUrl> RemoteTrailers { get; set; }
  27. public List<string> Keywords { get; set; }
  28. [IgnoreDataMember]
  29. public bool IsLocalTrailer
  30. {
  31. get { return TrailerTypes.Contains(TrailerType.LocalTrailer); }
  32. }
  33. /// <summary>
  34. /// Gets or sets the taglines.
  35. /// </summary>
  36. /// <value>The taglines.</value>
  37. public List<string> Taglines { get; set; }
  38. /// <summary>
  39. /// Gets or sets the budget.
  40. /// </summary>
  41. /// <value>The budget.</value>
  42. public double? Budget { get; set; }
  43. /// <summary>
  44. /// Gets or sets the revenue.
  45. /// </summary>
  46. /// <value>The revenue.</value>
  47. public double? Revenue { get; set; }
  48. public override UnratedItem GetBlockUnratedType()
  49. {
  50. return UnratedItem.Trailer;
  51. }
  52. public TrailerInfo GetLookupInfo()
  53. {
  54. var info = GetItemLookupInfo<TrailerInfo>();
  55. info.IsLocalTrailer = TrailerTypes.Contains(TrailerType.LocalTrailer);
  56. if (!IsInMixedFolder)
  57. {
  58. info.Name = System.IO.Path.GetFileName(ContainingFolderPath);
  59. }
  60. return info;
  61. }
  62. public override bool BeforeMetadataRefresh()
  63. {
  64. var hasChanges = base.BeforeMetadataRefresh();
  65. if (!ProductionYear.HasValue)
  66. {
  67. var info = LibraryManager.ParseName(Name);
  68. var yearInName = info.Year;
  69. if (yearInName.HasValue)
  70. {
  71. ProductionYear = yearInName;
  72. hasChanges = true;
  73. }
  74. else
  75. {
  76. // Try to get the year from the folder name
  77. if (!IsInMixedFolder)
  78. {
  79. info = LibraryManager.ParseName(System.IO.Path.GetFileName(ContainingFolderPath));
  80. yearInName = info.Year;
  81. if (yearInName.HasValue)
  82. {
  83. ProductionYear = yearInName;
  84. hasChanges = true;
  85. }
  86. }
  87. }
  88. }
  89. return hasChanges;
  90. }
  91. }
  92. }