BaseItemDto.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. using MediaBrowser.Model.Entities;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Runtime.Serialization;
  6. namespace MediaBrowser.Model.Dto
  7. {
  8. /// <summary>
  9. /// This is strictly used as a data transfer object from the api layer.
  10. /// This holds information about a BaseItem in a format that is convenient for the client.
  11. /// </summary>
  12. public class BaseItemDto : IHasProviderIds, INotifyPropertyChanged, IItemDto
  13. {
  14. /// <summary>
  15. /// Gets or sets the name.
  16. /// </summary>
  17. /// <value>The name.</value>
  18. public string Name { get; set; }
  19. /// <summary>
  20. /// Gets or sets the id.
  21. /// </summary>
  22. /// <value>The id.</value>
  23. public string Id { get; set; }
  24. /// <summary>
  25. /// Gets or sets the date created.
  26. /// </summary>
  27. /// <value>The date created.</value>
  28. public DateTime? DateCreated { get; set; }
  29. /// <summary>
  30. /// Gets or sets the name of the sort.
  31. /// </summary>
  32. /// <value>The name of the sort.</value>
  33. public string SortName { get; set; }
  34. /// <summary>
  35. /// Gets or sets the premiere date.
  36. /// </summary>
  37. /// <value>The premiere date.</value>
  38. public DateTime? PremiereDate { get; set; }
  39. /// <summary>
  40. /// Gets or sets the critic rating.
  41. /// </summary>
  42. /// <value>The critic rating.</value>
  43. public float? CriticRating { get; set; }
  44. /// <summary>
  45. /// Gets or sets the critic rating summary.
  46. /// </summary>
  47. /// <value>The critic rating summary.</value>
  48. public string CriticRatingSummary { get; set; }
  49. /// <summary>
  50. /// Gets or sets the path.
  51. /// </summary>
  52. /// <value>The path.</value>
  53. public string Path { get; set; }
  54. /// <summary>
  55. /// Gets or sets the official rating.
  56. /// </summary>
  57. /// <value>The official rating.</value>
  58. public string OfficialRating { get; set; }
  59. /// <summary>
  60. /// Gets or sets the overview.
  61. /// </summary>
  62. /// <value>The overview.</value>
  63. public string Overview { get; set; }
  64. /// <summary>
  65. /// Gets or sets the taglines.
  66. /// </summary>
  67. /// <value>The taglines.</value>
  68. public List<string> Taglines { get; set; }
  69. /// <summary>
  70. /// Gets or sets the genres.
  71. /// </summary>
  72. /// <value>The genres.</value>
  73. public List<string> Genres { get; set; }
  74. /// <summary>
  75. /// Gets or sets the community rating.
  76. /// </summary>
  77. /// <value>The community rating.</value>
  78. public float? CommunityRating { get; set; }
  79. /// <summary>
  80. /// Gets or sets the run time ticks.
  81. /// </summary>
  82. /// <value>The run time ticks.</value>
  83. public long? RunTimeTicks { get; set; }
  84. /// <summary>
  85. /// Gets or sets the aspect ratio.
  86. /// </summary>
  87. /// <value>The aspect ratio.</value>
  88. public string AspectRatio { get; set; }
  89. /// <summary>
  90. /// Gets or sets the production year.
  91. /// </summary>
  92. /// <value>The production year.</value>
  93. public int? ProductionYear { get; set; }
  94. /// <summary>
  95. /// Gets or sets the players supported by a game.
  96. /// </summary>
  97. /// <value>The players.</value>
  98. public int? Players { get; set; }
  99. /// <summary>
  100. /// Gets or sets the index number.
  101. /// </summary>
  102. /// <value>The index number.</value>
  103. public int? IndexNumber { get; set; }
  104. /// <summary>
  105. /// Gets or sets the index number end.
  106. /// </summary>
  107. /// <value>The index number end.</value>
  108. public int? IndexNumberEnd { get; set; }
  109. /// <summary>
  110. /// Gets or sets the parent index number.
  111. /// </summary>
  112. /// <value>The parent index number.</value>
  113. public int? ParentIndexNumber { get; set; }
  114. /// <summary>
  115. /// Gets or sets the trailer urls.
  116. /// </summary>
  117. /// <value>The trailer urls.</value>
  118. public List<string> TrailerUrls { get; set; }
  119. /// <summary>
  120. /// Gets or sets the provider ids.
  121. /// </summary>
  122. /// <value>The provider ids.</value>
  123. public Dictionary<string, string> ProviderIds { get; set; }
  124. /// <summary>
  125. /// Gets or sets the language.
  126. /// </summary>
  127. /// <value>The language.</value>
  128. public string Language { get; set; }
  129. /// <summary>
  130. /// Gets or sets a value indicating whether this instance is folder.
  131. /// </summary>
  132. /// <value><c>true</c> if this instance is folder; otherwise, <c>false</c>.</value>
  133. public bool IsFolder { get; set; }
  134. /// <summary>
  135. /// Gets or sets the parent id.
  136. /// </summary>
  137. /// <value>The parent id.</value>
  138. public string ParentId { get; set; }
  139. /// <summary>
  140. /// Gets or sets the type.
  141. /// </summary>
  142. /// <value>The type.</value>
  143. public string Type { get; set; }
  144. /// <summary>
  145. /// Gets or sets the people.
  146. /// </summary>
  147. /// <value>The people.</value>
  148. public BaseItemPerson[] People { get; set; }
  149. /// <summary>
  150. /// Gets or sets the studios.
  151. /// </summary>
  152. /// <value>The studios.</value>
  153. public StudioDto[] Studios { get; set; }
  154. /// <summary>
  155. /// If the item does not have a logo, this will hold the Id of the Parent that has one.
  156. /// </summary>
  157. /// <value>The parent logo item id.</value>
  158. public string ParentLogoItemId { get; set; }
  159. /// <summary>
  160. /// If the item does not have any backdrops, this will hold the Id of the Parent that has one.
  161. /// </summary>
  162. /// <value>The parent backdrop item id.</value>
  163. public string ParentBackdropItemId { get; set; }
  164. /// <summary>
  165. /// Gets or sets the parent backdrop image tags.
  166. /// </summary>
  167. /// <value>The parent backdrop image tags.</value>
  168. public List<Guid> ParentBackdropImageTags { get; set; }
  169. /// <summary>
  170. /// Gets or sets the local trailer count.
  171. /// </summary>
  172. /// <value>The local trailer count.</value>
  173. public int? LocalTrailerCount { get; set; }
  174. /// <summary>
  175. /// User data for this item based on the user it's being requested for
  176. /// </summary>
  177. /// <value>The user data.</value>
  178. public UserItemDataDto UserData { get; set; }
  179. /// <summary>
  180. /// Gets or sets the recently added item count.
  181. /// </summary>
  182. /// <value>The recently added item count.</value>
  183. public int? RecentlyAddedItemCount { get; set; }
  184. /// <summary>
  185. /// Gets or sets the played percentage.
  186. /// </summary>
  187. /// <value>The played percentage.</value>
  188. public double? PlayedPercentage { get; set; }
  189. /// <summary>
  190. /// Gets or sets the recursive item count.
  191. /// </summary>
  192. /// <value>The recursive item count.</value>
  193. public int? RecursiveItemCount { get; set; }
  194. /// <summary>
  195. /// Gets or sets the child count.
  196. /// </summary>
  197. /// <value>The child count.</value>
  198. public int? ChildCount { get; set; }
  199. /// <summary>
  200. /// Gets or sets the name of the series.
  201. /// </summary>
  202. /// <value>The name of the series.</value>
  203. public string SeriesName { get; set; }
  204. /// <summary>
  205. /// Gets or sets the series id.
  206. /// </summary>
  207. /// <value>The series id.</value>
  208. public string SeriesId { get; set; }
  209. /// <summary>
  210. /// Gets or sets the special feature count.
  211. /// </summary>
  212. /// <value>The special feature count.</value>
  213. public int? SpecialFeatureCount { get; set; }
  214. /// <summary>
  215. /// Gets or sets the display preferences id.
  216. /// </summary>
  217. /// <value>The display preferences id.</value>
  218. public string DisplayPreferencesId { get; set; }
  219. /// <summary>
  220. /// Gets or sets the status.
  221. /// </summary>
  222. /// <value>The status.</value>
  223. public SeriesStatus? Status { get; set; }
  224. /// <summary>
  225. /// Gets or sets the air time.
  226. /// </summary>
  227. /// <value>The air time.</value>
  228. public string AirTime { get; set; }
  229. /// <summary>
  230. /// Gets or sets the air days.
  231. /// </summary>
  232. /// <value>The air days.</value>
  233. public List<DayOfWeek> AirDays { get; set; }
  234. /// <summary>
  235. /// Gets or sets the index options.
  236. /// </summary>
  237. /// <value>The index options.</value>
  238. public string[] IndexOptions { get; set; }
  239. /// <summary>
  240. /// Gets or sets the tags.
  241. /// </summary>
  242. /// <value>The tags.</value>
  243. public List<string> Tags { get; set; }
  244. /// <summary>
  245. /// Gets or sets the primary image aspect ratio.
  246. /// </summary>
  247. /// <value>The primary image aspect ratio.</value>
  248. public double? PrimaryImageAspectRatio { get; set; }
  249. /// <summary>
  250. /// Gets or sets the artists.
  251. /// </summary>
  252. /// <value>The artists.</value>
  253. public string[] Artists { get; set; }
  254. /// <summary>
  255. /// Gets or sets the album.
  256. /// </summary>
  257. /// <value>The album.</value>
  258. public string Album { get; set; }
  259. /// <summary>
  260. /// Gets or sets the album artist.
  261. /// </summary>
  262. /// <value>The album artist.</value>
  263. public string AlbumArtist { get; set; }
  264. /// <summary>
  265. /// Gets or sets the media streams.
  266. /// </summary>
  267. /// <value>The media streams.</value>
  268. public List<MediaStream> MediaStreams { get; set; }
  269. /// <summary>
  270. /// Gets or sets the type of the video.
  271. /// </summary>
  272. /// <value>The type of the video.</value>
  273. public VideoType? VideoType { get; set; }
  274. /// <summary>
  275. /// Gets or sets the display type of the media.
  276. /// </summary>
  277. /// <value>The display type of the media.</value>
  278. public string DisplayMediaType { get; set; }
  279. /// <summary>
  280. /// Determines whether the specified type is type.
  281. /// </summary>
  282. /// <param name="type">The type.</param>
  283. /// <returns><c>true</c> if the specified type is type; otherwise, <c>false</c>.</returns>
  284. public bool IsType(Type type)
  285. {
  286. return IsType(type.Name);
  287. }
  288. /// <summary>
  289. /// Determines whether the specified type is type.
  290. /// </summary>
  291. /// <param name="type">The type.</param>
  292. /// <returns><c>true</c> if the specified type is type; otherwise, <c>false</c>.</returns>
  293. public bool IsType(string type)
  294. {
  295. return Type.Equals(type, StringComparison.OrdinalIgnoreCase);
  296. }
  297. /// <summary>
  298. /// Gets or sets the image tags.
  299. /// </summary>
  300. /// <value>The image tags.</value>
  301. public Dictionary<ImageType, Guid> ImageTags { get; set; }
  302. /// <summary>
  303. /// Gets or sets the backdrop image tags.
  304. /// </summary>
  305. /// <value>The backdrop image tags.</value>
  306. public List<Guid> BackdropImageTags { get; set; }
  307. /// <summary>
  308. /// Gets or sets the screenshot image tags.
  309. /// </summary>
  310. /// <value>The screenshot image tags.</value>
  311. public List<Guid> ScreenshotImageTags { get; set; }
  312. /// <summary>
  313. /// Gets or sets the parent logo image tag.
  314. /// </summary>
  315. /// <value>The parent logo image tag.</value>
  316. public Guid? ParentLogoImageTag { get; set; }
  317. /// <summary>
  318. /// Gets or sets the chapters.
  319. /// </summary>
  320. /// <value>The chapters.</value>
  321. public List<ChapterInfoDto> Chapters { get; set; }
  322. /// <summary>
  323. /// Gets or sets the video format.
  324. /// </summary>
  325. /// <value>The video format.</value>
  326. public VideoFormat? VideoFormat { get; set; }
  327. /// <summary>
  328. /// Gets or sets the type of the location.
  329. /// </summary>
  330. /// <value>The type of the location.</value>
  331. public LocationType LocationType { get; set; }
  332. /// <summary>
  333. /// Gets or sets the type of the iso.
  334. /// </summary>
  335. /// <value>The type of the iso.</value>
  336. public IsoType? IsoType { get; set; }
  337. /// <summary>
  338. /// Gets or sets the type of the media.
  339. /// </summary>
  340. /// <value>The type of the media.</value>
  341. public string MediaType { get; set; }
  342. /// <summary>
  343. /// Gets or sets the overview HTML.
  344. /// </summary>
  345. /// <value>The overview HTML.</value>
  346. public string OverviewHtml { get; set; }
  347. /// <summary>
  348. /// Gets or sets the end date.
  349. /// </summary>
  350. /// <value>The end date.</value>
  351. public DateTime? EndDate { get; set; }
  352. /// <summary>
  353. /// Gets or sets the home page URL.
  354. /// </summary>
  355. /// <value>The home page URL.</value>
  356. public string HomePageUrl { get; set; }
  357. /// <summary>
  358. /// Gets or sets the production locations.
  359. /// </summary>
  360. /// <value>The production locations.</value>
  361. public List<string> ProductionLocations { get; set; }
  362. /// <summary>
  363. /// Gets or sets the budget.
  364. /// </summary>
  365. /// <value>The budget.</value>
  366. public double? Budget { get; set; }
  367. /// <summary>
  368. /// Gets or sets the revenue.
  369. /// </summary>
  370. /// <value>The revenue.</value>
  371. public double? Revenue { get; set; }
  372. /// <summary>
  373. /// Gets a value indicating whether this instance can resume.
  374. /// </summary>
  375. /// <value><c>true</c> if this instance can resume; otherwise, <c>false</c>.</value>
  376. [IgnoreDataMember]
  377. public bool CanResume
  378. {
  379. get { return UserData != null && UserData.PlaybackPositionTicks > 0; }
  380. }
  381. /// <summary>
  382. /// Gets the resume position ticks.
  383. /// </summary>
  384. /// <value>The resume position ticks.</value>
  385. [IgnoreDataMember]
  386. public long ResumePositionTicks
  387. {
  388. get { return UserData == null ? 0 : UserData.PlaybackPositionTicks; }
  389. }
  390. /// <summary>
  391. /// Gets the backdrop count.
  392. /// </summary>
  393. /// <value>The backdrop count.</value>
  394. [IgnoreDataMember]
  395. public int BackdropCount
  396. {
  397. get { return BackdropImageTags == null ? 0 : BackdropImageTags.Count; }
  398. }
  399. /// <summary>
  400. /// Gets the screenshot count.
  401. /// </summary>
  402. /// <value>The screenshot count.</value>
  403. [IgnoreDataMember]
  404. public int ScreenshotCount
  405. {
  406. get { return ScreenshotImageTags == null ? 0 : ScreenshotImageTags.Count; }
  407. }
  408. /// <summary>
  409. /// Gets a value indicating whether this instance has banner.
  410. /// </summary>
  411. /// <value><c>true</c> if this instance has banner; otherwise, <c>false</c>.</value>
  412. [IgnoreDataMember]
  413. public bool HasBanner
  414. {
  415. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Banner); }
  416. }
  417. /// <summary>
  418. /// Gets a value indicating whether this instance has art.
  419. /// </summary>
  420. /// <value><c>true</c> if this instance has art; otherwise, <c>false</c>.</value>
  421. [IgnoreDataMember]
  422. public bool HasArtImage
  423. {
  424. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Art); }
  425. }
  426. /// <summary>
  427. /// Gets a value indicating whether this instance has logo.
  428. /// </summary>
  429. /// <value><c>true</c> if this instance has logo; otherwise, <c>false</c>.</value>
  430. [IgnoreDataMember]
  431. public bool HasLogo
  432. {
  433. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Logo); }
  434. }
  435. /// <summary>
  436. /// Gets a value indicating whether this instance has thumb.
  437. /// </summary>
  438. /// <value><c>true</c> if this instance has thumb; otherwise, <c>false</c>.</value>
  439. [IgnoreDataMember]
  440. public bool HasThumb
  441. {
  442. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Thumb); }
  443. }
  444. /// <summary>
  445. /// Gets a value indicating whether this instance has primary image.
  446. /// </summary>
  447. /// <value><c>true</c> if this instance has primary image; otherwise, <c>false</c>.</value>
  448. [IgnoreDataMember]
  449. public bool HasPrimaryImage
  450. {
  451. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Primary); }
  452. }
  453. /// <summary>
  454. /// Gets a value indicating whether this instance has disc image.
  455. /// </summary>
  456. /// <value><c>true</c> if this instance has disc image; otherwise, <c>false</c>.</value>
  457. [IgnoreDataMember]
  458. public bool HasDiscImage
  459. {
  460. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Disc); }
  461. }
  462. /// <summary>
  463. /// Gets a value indicating whether this instance has box image.
  464. /// </summary>
  465. /// <value><c>true</c> if this instance has box image; otherwise, <c>false</c>.</value>
  466. [IgnoreDataMember]
  467. public bool HasBoxImage
  468. {
  469. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Box); }
  470. }
  471. /// <summary>
  472. /// Gets a value indicating whether this instance has menu image.
  473. /// </summary>
  474. /// <value><c>true</c> if this instance has menu image; otherwise, <c>false</c>.</value>
  475. [IgnoreDataMember]
  476. public bool HasMenuImage
  477. {
  478. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Menu); }
  479. }
  480. /// <summary>
  481. /// Gets a value indicating whether this instance is video.
  482. /// </summary>
  483. /// <value><c>true</c> if this instance is video; otherwise, <c>false</c>.</value>
  484. [IgnoreDataMember]
  485. public bool HasTrailer
  486. {
  487. get { return LocalTrailerCount > 0 || (TrailerUrls != null && TrailerUrls.Count > 0); }
  488. }
  489. /// <summary>
  490. /// Gets a value indicating whether this instance is video.
  491. /// </summary>
  492. /// <value><c>true</c> if this instance is video; otherwise, <c>false</c>.</value>
  493. [IgnoreDataMember]
  494. public bool IsVideo
  495. {
  496. get { return string.Equals(MediaType, Entities.MediaType.Video, StringComparison.OrdinalIgnoreCase); }
  497. }
  498. /// <summary>
  499. /// Gets a value indicating whether this instance is audio.
  500. /// </summary>
  501. /// <value><c>true</c> if this instance is audio; otherwise, <c>false</c>.</value>
  502. [IgnoreDataMember]
  503. public bool IsAudio
  504. {
  505. get { return string.Equals(MediaType, Entities.MediaType.Audio, StringComparison.OrdinalIgnoreCase); }
  506. }
  507. /// <summary>
  508. /// Gets a value indicating whether this instance is game.
  509. /// </summary>
  510. /// <value><c>true</c> if this instance is game; otherwise, <c>false</c>.</value>
  511. [IgnoreDataMember]
  512. public bool IsGame
  513. {
  514. get { return string.Equals(MediaType, Entities.MediaType.Game, StringComparison.OrdinalIgnoreCase); }
  515. }
  516. /// <summary>
  517. /// Gets a value indicating whether this instance is person.
  518. /// </summary>
  519. /// <value><c>true</c> if this instance is person; otherwise, <c>false</c>.</value>
  520. [IgnoreDataMember]
  521. public bool IsPerson
  522. {
  523. get { return string.Equals(Type, "Person", StringComparison.OrdinalIgnoreCase); }
  524. }
  525. /// <summary>
  526. /// Gets a value indicating whether this instance is root.
  527. /// </summary>
  528. /// <value><c>true</c> if this instance is root; otherwise, <c>false</c>.</value>
  529. [IgnoreDataMember]
  530. public bool IsRoot
  531. {
  532. get { return string.Equals(Type, "AggregateFolder", StringComparison.OrdinalIgnoreCase); }
  533. }
  534. /// <summary>
  535. /// Occurs when [property changed].
  536. /// </summary>
  537. public event PropertyChangedEventHandler PropertyChanged;
  538. }
  539. }