Game.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 System.Runtime.Serialization;
  8. namespace MediaBrowser.Controller.Entities
  9. {
  10. public class Game : BaseItem, IHasTrailers, IHasThemeMedia, 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. [IgnoreDataMember]
  32. public override bool EnableRefreshOnDateModifiedChange
  33. {
  34. get { return true; }
  35. }
  36. /// <summary>
  37. /// Gets or sets the remote trailers.
  38. /// </summary>
  39. /// <value>The remote trailers.</value>
  40. public List<MediaUrl> RemoteTrailers { get; set; }
  41. /// <summary>
  42. /// Gets the type of the media.
  43. /// </summary>
  44. /// <value>The type of the media.</value>
  45. [IgnoreDataMember]
  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. public override List<string> GetUserDataKeys()
  75. {
  76. var list = base.GetUserDataKeys();
  77. var id = this.GetProviderId(MetadataProviders.Gamesdb);
  78. if (!string.IsNullOrEmpty(id))
  79. {
  80. list.Insert(0, "Game-Gamesdb-" + id);
  81. }
  82. return list;
  83. }
  84. public override IEnumerable<string> GetDeletePaths()
  85. {
  86. if (!IsInMixedFolder)
  87. {
  88. return new[] { System.IO.Path.GetDirectoryName(Path) };
  89. }
  90. return base.GetDeletePaths();
  91. }
  92. public override UnratedItem GetBlockUnratedType()
  93. {
  94. return UnratedItem.Game;
  95. }
  96. public GameInfo GetLookupInfo()
  97. {
  98. var id = GetItemLookupInfo<GameInfo>();
  99. id.GameSystem = GameSystem;
  100. return id;
  101. }
  102. /// <summary>
  103. /// Gets the trailer ids.
  104. /// </summary>
  105. /// <returns>List&lt;Guid&gt;.</returns>
  106. public List<Guid> GetTrailerIds()
  107. {
  108. var list = LocalTrailerIds.ToList();
  109. list.AddRange(RemoteTrailerIds);
  110. return list;
  111. }
  112. }
  113. }