Game.cs 4.1 KB

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