2
0

Game.cs 4.4 KB

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