Game.cs 3.8 KB

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