Game.cs 4.3 KB

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