Game.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. using MediaBrowser.Controller.Providers;
  2. using MediaBrowser.Model.Configuration;
  3. using MediaBrowser.Model.Entities;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Runtime.Serialization;
  8. namespace MediaBrowser.Controller.Entities
  9. {
  10. public class Game : BaseItem, IHasTrailers, IHasScreenshots, ISupportsPlaceHolders, IHasLookupInfo<GameInfo>
  11. {
  12. public Game()
  13. {
  14. MultiPartGameFiles = new List<string>();
  15. RemoteTrailers = new List<MediaUrl>();
  16. LocalTrailerIds = new List<Guid>();
  17. RemoteTrailerIds = new List<Guid>();
  18. }
  19. public List<Guid> LocalTrailerIds { get; set; }
  20. public List<Guid> RemoteTrailerIds { get; set; }
  21. public override bool CanDownload()
  22. {
  23. var locationType = LocationType;
  24. return locationType != LocationType.Remote &&
  25. locationType != LocationType.Virtual;
  26. }
  27. [IgnoreDataMember]
  28. public override bool EnableRefreshOnDateModifiedChange
  29. {
  30. get { return true; }
  31. }
  32. [IgnoreDataMember]
  33. public override bool SupportsThemeMedia
  34. {
  35. get { return true; }
  36. }
  37. /// <summary>
  38. /// Gets or sets the remote trailers.
  39. /// </summary>
  40. /// <value>The remote trailers.</value>
  41. public List<MediaUrl> RemoteTrailers { get; set; }
  42. /// <summary>
  43. /// Gets the type of the media.
  44. /// </summary>
  45. /// <value>The type of the media.</value>
  46. [IgnoreDataMember]
  47. public override string MediaType
  48. {
  49. get { return Model.Entities.MediaType.Game; }
  50. }
  51. /// <summary>
  52. /// Gets or sets the players supported.
  53. /// </summary>
  54. /// <value>The players supported.</value>
  55. public int? PlayersSupported { get; set; }
  56. /// <summary>
  57. /// Gets a value indicating whether this instance is place holder.
  58. /// </summary>
  59. /// <value><c>true</c> if this instance is place holder; otherwise, <c>false</c>.</value>
  60. public bool IsPlaceHolder { get; set; }
  61. /// <summary>
  62. /// Gets or sets the game system.
  63. /// </summary>
  64. /// <value>The game system.</value>
  65. public string GameSystem { get; set; }
  66. /// <summary>
  67. /// Gets or sets a value indicating whether this instance is multi part.
  68. /// </summary>
  69. /// <value><c>true</c> if this instance is multi part; otherwise, <c>false</c>.</value>
  70. public bool IsMultiPart { get; set; }
  71. /// <summary>
  72. /// Holds the paths to the game files in the event this is a multipart game
  73. /// </summary>
  74. public List<string> MultiPartGameFiles { get; set; }
  75. public override List<string> GetUserDataKeys()
  76. {
  77. var list = base.GetUserDataKeys();
  78. var id = this.GetProviderId(MetadataProviders.Gamesdb);
  79. if (!string.IsNullOrEmpty(id))
  80. {
  81. list.Insert(0, "Game-Gamesdb-" + id);
  82. }
  83. return list;
  84. }
  85. public override IEnumerable<string> GetDeletePaths()
  86. {
  87. if (!DetectIsInMixedFolder())
  88. {
  89. return new[] { System.IO.Path.GetDirectoryName(Path) };
  90. }
  91. return base.GetDeletePaths();
  92. }
  93. public override UnratedItem GetBlockUnratedType()
  94. {
  95. return UnratedItem.Game;
  96. }
  97. public GameInfo GetLookupInfo()
  98. {
  99. var id = GetItemLookupInfo<GameInfo>();
  100. id.GameSystem = GameSystem;
  101. return id;
  102. }
  103. /// <summary>
  104. /// Gets the trailer ids.
  105. /// </summary>
  106. /// <returns>List&lt;Guid&gt;.</returns>
  107. public List<Guid> GetTrailerIds()
  108. {
  109. var list = LocalTrailerIds.ToList();
  110. list.AddRange(RemoteTrailerIds);
  111. return list;
  112. }
  113. }
  114. }