Game.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 MediaBrowser.Model.IO;
  7. using MediaBrowser.Model.Serialization;
  8. namespace MediaBrowser.Controller.Entities
  9. {
  10. public class Game : BaseItem, IHasTrailers, IHasScreenshots, ISupportsPlaceHolders, IHasLookupInfo<GameInfo>
  11. {
  12. public Game()
  13. {
  14. MultiPartGameFiles = EmptyStringArray;
  15. RemoteTrailers = EmptyMediaUrlArray;
  16. LocalTrailerIds = EmptyGuidArray;
  17. RemoteTrailerIds = EmptyGuidArray;
  18. }
  19. public Guid[] LocalTrailerIds { get; set; }
  20. public 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 SupportsThemeMedia
  29. {
  30. get { return true; }
  31. }
  32. [IgnoreDataMember]
  33. public override bool SupportsPeople
  34. {
  35. get { return false; }
  36. }
  37. /// <summary>
  38. /// Gets or sets the remote trailers.
  39. /// </summary>
  40. /// <value>The remote trailers.</value>
  41. public 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 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<FileSystemMetadata> GetDeletePaths()
  86. {
  87. if (!IsInMixedFolder)
  88. {
  89. return new[] {
  90. new FileSystemMetadata
  91. {
  92. FullName = FileSystem.GetDirectoryName(Path),
  93. IsDirectory = true
  94. }
  95. };
  96. }
  97. return base.GetDeletePaths();
  98. }
  99. public override UnratedItem GetBlockUnratedType()
  100. {
  101. return UnratedItem.Game;
  102. }
  103. public GameInfo GetLookupInfo()
  104. {
  105. var id = GetItemLookupInfo<GameInfo>();
  106. id.GameSystem = GameSystem;
  107. return id;
  108. }
  109. }
  110. }