Game.cs 4.0 KB

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