BaseItemDto.cs 21 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
  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. /// If the item is a Folder this will determine if it's the Root or not
  138. /// </summary>
  139. /// <value><c>null</c> if [is root] contains no value, <c>true</c> if [is root]; otherwise, <c>false</c>.</value>
  140. [ProtoMember(26)]
  141. public bool? IsRoot { get; set; }
  142. /// <summary>
  143. /// If the item is a Folder this will determine if it's a VF or not
  144. /// </summary>
  145. /// <value><c>null</c> if [is virtual folder] contains no value, <c>true</c> if [is virtual folder]; otherwise, <c>false</c>.</value>
  146. [ProtoMember(27)]
  147. public bool? IsVirtualFolder { get; set; }
  148. /// <summary>
  149. /// Gets or sets the parent id.
  150. /// </summary>
  151. /// <value>The parent id.</value>
  152. [ProtoMember(28)]
  153. public string ParentId { get; set; }
  154. /// <summary>
  155. /// Gets or sets the type.
  156. /// </summary>
  157. /// <value>The type.</value>
  158. [ProtoMember(29)]
  159. public string Type { get; set; }
  160. /// <summary>
  161. /// Gets or sets the people.
  162. /// </summary>
  163. /// <value>The people.</value>
  164. [ProtoMember(30)]
  165. public BaseItemPerson[] People { get; set; }
  166. /// <summary>
  167. /// Gets or sets the studios.
  168. /// </summary>
  169. /// <value>The studios.</value>
  170. [ProtoMember(31)]
  171. public List<string> Studios { get; set; }
  172. /// <summary>
  173. /// If the item does not have a logo, this will hold the Id of the Parent that has one.
  174. /// </summary>
  175. /// <value>The parent logo item id.</value>
  176. [ProtoMember(32)]
  177. public string ParentLogoItemId { get; set; }
  178. /// <summary>
  179. /// If the item does not have any backdrops, this will hold the Id of the Parent that has one.
  180. /// </summary>
  181. /// <value>The parent backdrop item id.</value>
  182. [ProtoMember(33)]
  183. public string ParentBackdropItemId { get; set; }
  184. /// <summary>
  185. /// Gets or sets the parent backdrop image tags.
  186. /// </summary>
  187. /// <value>The parent backdrop image tags.</value>
  188. [ProtoMember(34)]
  189. public List<Guid> ParentBackdropImageTags { get; set; }
  190. /// <summary>
  191. /// Gets or sets the local trailer count.
  192. /// </summary>
  193. /// <value>The local trailer count.</value>
  194. [ProtoMember(35)]
  195. public int? LocalTrailerCount { get; set; }
  196. /// <summary>
  197. /// User data for this item based on the user it's being requested for
  198. /// </summary>
  199. /// <value>The user data.</value>
  200. [ProtoMember(36)]
  201. public UserItemDataDto UserData { get; set; }
  202. /// <summary>
  203. /// Gets or sets a value indicating whether this instance is new.
  204. /// </summary>
  205. /// <value><c>true</c> if this instance is new; otherwise, <c>false</c>.</value>
  206. [ProtoMember(37)]
  207. public bool IsNew { get; set; }
  208. /// <summary>
  209. /// Gets or sets the recently added item count.
  210. /// </summary>
  211. /// <value>The recently added item count.</value>
  212. [ProtoMember(38)]
  213. public int? RecentlyAddedItemCount { get; set; }
  214. /// <summary>
  215. /// Gets or sets the recently added un played item count.
  216. /// </summary>
  217. /// <value>The recently added un played item count.</value>
  218. [ProtoMember(39)]
  219. public int? RecentlyAddedUnPlayedItemCount { get; set; }
  220. /// <summary>
  221. /// Gets or sets the resumable item count.
  222. /// </summary>
  223. /// <value>The resumable item count.</value>
  224. [ProtoMember(40)]
  225. public int? ResumableItemCount { get; set; }
  226. /// <summary>
  227. /// Gets or sets the played percentage.
  228. /// </summary>
  229. /// <value>The played percentage.</value>
  230. [ProtoMember(41)]
  231. public double? PlayedPercentage { get; set; }
  232. /// <summary>
  233. /// Gets or sets the recursive item count.
  234. /// </summary>
  235. /// <value>The recursive item count.</value>
  236. [ProtoMember(42)]
  237. public int? RecursiveItemCount { get; set; }
  238. /// <summary>
  239. /// Gets or sets the favorite item count.
  240. /// </summary>
  241. /// <value>The favorite item count.</value>
  242. [ProtoMember(43)]
  243. public int? FavoriteItemCount { get; set; }
  244. /// <summary>
  245. /// Gets or sets the child count.
  246. /// </summary>
  247. /// <value>The child count.</value>
  248. [ProtoMember(44)]
  249. public int? ChildCount { get; set; }
  250. /// <summary>
  251. /// Gets or sets the name of the series.
  252. /// </summary>
  253. /// <value>The name of the series.</value>
  254. [ProtoMember(45)]
  255. public string SeriesName { get; set; }
  256. /// <summary>
  257. /// Gets or sets the series id.
  258. /// </summary>
  259. /// <value>The series id.</value>
  260. [ProtoMember(46)]
  261. public string SeriesId { get; set; }
  262. /// <summary>
  263. /// Gets or sets the recently played item count.
  264. /// </summary>
  265. /// <value>The recently played item count.</value>
  266. [ProtoMember(47)]
  267. public int? RecentlyPlayedItemCount { get; set; }
  268. /// <summary>
  269. /// Gets or sets the special feature count.
  270. /// </summary>
  271. /// <value>The special feature count.</value>
  272. [ProtoMember(48)]
  273. public int? SpecialFeatureCount { get; set; }
  274. /// <summary>
  275. /// Gets or sets the display preferences.
  276. /// </summary>
  277. /// <value>The display preferences.</value>
  278. [ProtoMember(49)]
  279. public DisplayPreferences DisplayPreferences { get; set; }
  280. /// <summary>
  281. /// Gets or sets the status.
  282. /// </summary>
  283. /// <value>The status.</value>
  284. [ProtoMember(50)]
  285. public SeriesStatus? Status { get; set; }
  286. /// <summary>
  287. /// Gets or sets the air time.
  288. /// </summary>
  289. /// <value>The air time.</value>
  290. [ProtoMember(51)]
  291. public string AirTime { get; set; }
  292. /// <summary>
  293. /// Gets or sets the air days.
  294. /// </summary>
  295. /// <value>The air days.</value>
  296. [ProtoMember(52)]
  297. public List<DayOfWeek> AirDays { get; set; }
  298. /// <summary>
  299. /// Gets or sets the sort options.
  300. /// </summary>
  301. /// <value>The sort options.</value>
  302. [ProtoMember(53)]
  303. public string[] SortOptions { get; set; }
  304. /// <summary>
  305. /// Gets or sets the index options.
  306. /// </summary>
  307. /// <value>The index options.</value>
  308. [ProtoMember(54)]
  309. public string[] IndexOptions { get; set; }
  310. /// <summary>
  311. /// Gets or sets the primary image aspect ratio.
  312. /// </summary>
  313. /// <value>The primary image aspect ratio.</value>
  314. [ProtoMember(55)]
  315. public double? PrimaryImageAspectRatio { get; set; }
  316. /// <summary>
  317. /// Gets or sets the artist.
  318. /// </summary>
  319. /// <value>The artist.</value>
  320. [ProtoMember(56)]
  321. public string Artist { get; set; }
  322. /// <summary>
  323. /// Gets or sets the album.
  324. /// </summary>
  325. /// <value>The album.</value>
  326. [ProtoMember(57)]
  327. public string Album { get; set; }
  328. /// <summary>
  329. /// Gets or sets the album artist.
  330. /// </summary>
  331. /// <value>The album artist.</value>
  332. [ProtoMember(58)]
  333. public string AlbumArtist { get; set; }
  334. /// <summary>
  335. /// Gets or sets the media streams.
  336. /// </summary>
  337. /// <value>The media streams.</value>
  338. [ProtoMember(59)]
  339. public List<MediaStream> MediaStreams { get; set; }
  340. /// <summary>
  341. /// Gets or sets the type of the video.
  342. /// </summary>
  343. /// <value>The type of the video.</value>
  344. [ProtoMember(60)]
  345. public VideoType? VideoType { get; set; }
  346. /// <summary>
  347. /// Gets or sets the display type of the media.
  348. /// </summary>
  349. /// <value>The display type of the media.</value>
  350. [ProtoMember(61)]
  351. public string DisplayMediaType { get; set; }
  352. /// <summary>
  353. /// Determines whether the specified type is type.
  354. /// </summary>
  355. /// <param name="type">The type.</param>
  356. /// <returns><c>true</c> if the specified type is type; otherwise, <c>false</c>.</returns>
  357. public bool IsType(Type type)
  358. {
  359. return IsType(type.Name);
  360. }
  361. /// <summary>
  362. /// Determines whether the specified type is type.
  363. /// </summary>
  364. /// <param name="type">The type.</param>
  365. /// <returns><c>true</c> if the specified type is type; otherwise, <c>false</c>.</returns>
  366. public bool IsType(string type)
  367. {
  368. return Type.Equals(type, StringComparison.OrdinalIgnoreCase);
  369. }
  370. /// <summary>
  371. /// Gets a value indicating whether this instance can resume.
  372. /// </summary>
  373. /// <value><c>true</c> if this instance can resume; otherwise, <c>false</c>.</value>
  374. [IgnoreDataMember]
  375. public bool CanResume
  376. {
  377. get { return UserData != null && UserData.PlaybackPositionTicks > 0; }
  378. }
  379. /// <summary>
  380. /// Gets the resume position ticks.
  381. /// </summary>
  382. /// <value>The resume position ticks.</value>
  383. [IgnoreDataMember]
  384. public long ResumePositionTicks
  385. {
  386. get { return UserData == null ? 0 : UserData.PlaybackPositionTicks; }
  387. }
  388. /// <summary>
  389. /// Gets or sets the image tags.
  390. /// </summary>
  391. /// <value>The image tags.</value>
  392. [ProtoMember(62)]
  393. public Dictionary<ImageType, Guid> ImageTags { get; set; }
  394. /// <summary>
  395. /// Gets or sets the backdrop image tags.
  396. /// </summary>
  397. /// <value>The backdrop image tags.</value>
  398. [ProtoMember(63)]
  399. public List<Guid> BackdropImageTags { get; set; }
  400. /// <summary>
  401. /// Gets or sets the parent logo image tag.
  402. /// </summary>
  403. /// <value>The parent logo image tag.</value>
  404. [ProtoMember(64)]
  405. public Guid? ParentLogoImageTag { get; set; }
  406. /// <summary>
  407. /// Gets or sets the chapters.
  408. /// </summary>
  409. /// <value>The chapters.</value>
  410. [ProtoMember(65)]
  411. public List<ChapterInfoDto> Chapters { get; set; }
  412. /// <summary>
  413. /// Gets or sets the video format.
  414. /// </summary>
  415. /// <value>The video format.</value>
  416. [ProtoMember(66)]
  417. public VideoFormat? VideoFormat { get; set; }
  418. /// <summary>
  419. /// Gets or sets the type of the location.
  420. /// </summary>
  421. /// <value>The type of the location.</value>
  422. [ProtoMember(67)]
  423. public LocationType LocationType { get; set; }
  424. /// <summary>
  425. /// Gets or sets the type of the iso.
  426. /// </summary>
  427. /// <value>The type of the iso.</value>
  428. [ProtoMember(68)]
  429. public IsoType? IsoType { get; set; }
  430. /// <summary>
  431. /// Gets or sets the type of the media.
  432. /// </summary>
  433. /// <value>The type of the media.</value>
  434. [ProtoMember(69)]
  435. public string MediaType { get; set; }
  436. /// <summary>
  437. /// Gets the backdrop count.
  438. /// </summary>
  439. /// <value>The backdrop count.</value>
  440. [IgnoreDataMember]
  441. public int BackdropCount
  442. {
  443. get { return BackdropImageTags == null ? 0 : BackdropImageTags.Count; }
  444. }
  445. /// <summary>
  446. /// Gets a value indicating whether this instance has banner.
  447. /// </summary>
  448. /// <value><c>true</c> if this instance has banner; otherwise, <c>false</c>.</value>
  449. [IgnoreDataMember]
  450. public bool HasBanner
  451. {
  452. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Banner); }
  453. }
  454. /// <summary>
  455. /// Gets a value indicating whether this instance has art.
  456. /// </summary>
  457. /// <value><c>true</c> if this instance has art; otherwise, <c>false</c>.</value>
  458. [IgnoreDataMember]
  459. public bool HasArtImage
  460. {
  461. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Art); }
  462. }
  463. /// <summary>
  464. /// Gets a value indicating whether this instance has logo.
  465. /// </summary>
  466. /// <value><c>true</c> if this instance has logo; otherwise, <c>false</c>.</value>
  467. [IgnoreDataMember]
  468. public bool HasLogo
  469. {
  470. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Logo); }
  471. }
  472. /// <summary>
  473. /// Gets a value indicating whether this instance has thumb.
  474. /// </summary>
  475. /// <value><c>true</c> if this instance has thumb; otherwise, <c>false</c>.</value>
  476. [IgnoreDataMember]
  477. public bool HasThumb
  478. {
  479. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Thumb); }
  480. }
  481. /// <summary>
  482. /// Gets a value indicating whether this instance has primary image.
  483. /// </summary>
  484. /// <value><c>true</c> if this instance has primary image; otherwise, <c>false</c>.</value>
  485. [IgnoreDataMember]
  486. public bool HasPrimaryImage
  487. {
  488. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Primary); }
  489. }
  490. /// <summary>
  491. /// Gets a value indicating whether this instance has disc image.
  492. /// </summary>
  493. /// <value><c>true</c> if this instance has disc image; otherwise, <c>false</c>.</value>
  494. [IgnoreDataMember]
  495. public bool HasDiscImage
  496. {
  497. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Disc); }
  498. }
  499. /// <summary>
  500. /// Gets a value indicating whether this instance has box image.
  501. /// </summary>
  502. /// <value><c>true</c> if this instance has box image; otherwise, <c>false</c>.</value>
  503. [IgnoreDataMember]
  504. public bool HasBoxImage
  505. {
  506. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Box); }
  507. }
  508. /// <summary>
  509. /// Gets a value indicating whether this instance has menu image.
  510. /// </summary>
  511. /// <value><c>true</c> if this instance has menu image; otherwise, <c>false</c>.</value>
  512. public bool HasMenuImage
  513. {
  514. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Menu); }
  515. }
  516. /// <summary>
  517. /// Gets a value indicating whether this instance is video.
  518. /// </summary>
  519. /// <value><c>true</c> if this instance is video; otherwise, <c>false</c>.</value>
  520. [IgnoreDataMember]
  521. public bool HasTrailer
  522. {
  523. get { return LocalTrailerCount > 0 || (TrailerUrls != null && TrailerUrls.Count > 0); }
  524. }
  525. /// <summary>
  526. /// Gets a value indicating whether this instance is video.
  527. /// </summary>
  528. /// <value><c>true</c> if this instance is video; otherwise, <c>false</c>.</value>
  529. [IgnoreDataMember]
  530. public bool IsVideo
  531. {
  532. get { return string.Equals(MediaType, Entities.MediaType.Video, StringComparison.OrdinalIgnoreCase); }
  533. }
  534. /// <summary>
  535. /// Gets a value indicating whether this instance is audio.
  536. /// </summary>
  537. /// <value><c>true</c> if this instance is audio; otherwise, <c>false</c>.</value>
  538. [IgnoreDataMember]
  539. public bool IsAudio
  540. {
  541. get { return string.Equals(MediaType, Entities.MediaType.Audio, StringComparison.OrdinalIgnoreCase); }
  542. }
  543. /// <summary>
  544. /// Gets a value indicating whether this instance is game.
  545. /// </summary>
  546. /// <value><c>true</c> if this instance is game; otherwise, <c>false</c>.</value>
  547. [IgnoreDataMember]
  548. public bool IsGame
  549. {
  550. get { return string.Equals(MediaType, Entities.MediaType.Game, StringComparison.OrdinalIgnoreCase); }
  551. }
  552. /// <summary>
  553. /// Occurs when [property changed].
  554. /// </summary>
  555. public event PropertyChangedEventHandler PropertyChanged;
  556. }
  557. }