Game.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. /// <summary>
  33. /// Gets or sets the remote trailers.
  34. /// </summary>
  35. /// <value>The remote trailers.</value>
  36. public MediaUrl[] RemoteTrailers { get; set; }
  37. /// <summary>
  38. /// Gets the type of the media.
  39. /// </summary>
  40. /// <value>The type of the media.</value>
  41. [IgnoreDataMember]
  42. public override string MediaType
  43. {
  44. get { return Model.Entities.MediaType.Game; }
  45. }
  46. /// <summary>
  47. /// Gets or sets the players supported.
  48. /// </summary>
  49. /// <value>The players supported.</value>
  50. public int? PlayersSupported { get; set; }
  51. /// <summary>
  52. /// Gets a value indicating whether this instance is place holder.
  53. /// </summary>
  54. /// <value><c>true</c> if this instance is place holder; otherwise, <c>false</c>.</value>
  55. public bool IsPlaceHolder { get; set; }
  56. /// <summary>
  57. /// Gets or sets the game system.
  58. /// </summary>
  59. /// <value>The game system.</value>
  60. public string GameSystem { get; set; }
  61. /// <summary>
  62. /// Gets or sets a value indicating whether this instance is multi part.
  63. /// </summary>
  64. /// <value><c>true</c> if this instance is multi part; otherwise, <c>false</c>.</value>
  65. public bool IsMultiPart { get; set; }
  66. /// <summary>
  67. /// Holds the paths to the game files in the event this is a multipart game
  68. /// </summary>
  69. public string[] MultiPartGameFiles { get; set; }
  70. public override List<string> GetUserDataKeys()
  71. {
  72. var list = base.GetUserDataKeys();
  73. var id = this.GetProviderId(MetadataProviders.Gamesdb);
  74. if (!string.IsNullOrEmpty(id))
  75. {
  76. list.Insert(0, "Game-Gamesdb-" + id);
  77. }
  78. return list;
  79. }
  80. public override IEnumerable<FileSystemMetadata> GetDeletePaths()
  81. {
  82. if (!IsInMixedFolder)
  83. {
  84. return new[] {
  85. new FileSystemMetadata
  86. {
  87. FullName = FileSystem.GetDirectoryName(Path),
  88. IsDirectory = true
  89. }
  90. };
  91. }
  92. return base.GetDeletePaths();
  93. }
  94. public override UnratedItem GetBlockUnratedType()
  95. {
  96. return UnratedItem.Game;
  97. }
  98. public GameInfo GetLookupInfo()
  99. {
  100. var id = GetItemLookupInfo<GameInfo>();
  101. id.GameSystem = GameSystem;
  102. return id;
  103. }
  104. }
  105. }