Game.cs 4.2 KB

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