BaseItemDto.cs 20 KB

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