BaseItemDto.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  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 a value indicating whether this instance is new.
  192. /// </summary>
  193. /// <value><c>true</c> if this instance is new; otherwise, <c>false</c>.</value>
  194. [ProtoMember(37)]
  195. public bool IsNew { get; set; }
  196. /// <summary>
  197. /// Gets or sets the recently added item count.
  198. /// </summary>
  199. /// <value>The recently added item count.</value>
  200. [ProtoMember(38)]
  201. public int? RecentlyAddedItemCount { get; set; }
  202. /// <summary>
  203. /// Gets or sets the played percentage.
  204. /// </summary>
  205. /// <value>The played percentage.</value>
  206. [ProtoMember(41)]
  207. public double? PlayedPercentage { get; set; }
  208. /// <summary>
  209. /// Gets or sets the recursive item count.
  210. /// </summary>
  211. /// <value>The recursive item count.</value>
  212. [ProtoMember(42)]
  213. public int? RecursiveItemCount { get; set; }
  214. /// <summary>
  215. /// Gets or sets the child count.
  216. /// </summary>
  217. /// <value>The child count.</value>
  218. [ProtoMember(44)]
  219. public int? ChildCount { get; set; }
  220. /// <summary>
  221. /// Gets or sets the name of the series.
  222. /// </summary>
  223. /// <value>The name of the series.</value>
  224. [ProtoMember(45)]
  225. public string SeriesName { get; set; }
  226. /// <summary>
  227. /// Gets or sets the series id.
  228. /// </summary>
  229. /// <value>The series id.</value>
  230. [ProtoMember(46)]
  231. public string SeriesId { get; set; }
  232. /// <summary>
  233. /// Gets or sets the special feature count.
  234. /// </summary>
  235. /// <value>The special feature count.</value>
  236. [ProtoMember(48)]
  237. public int? SpecialFeatureCount { get; set; }
  238. /// <summary>
  239. /// Gets or sets the display preferences.
  240. /// </summary>
  241. /// <value>The display preferences.</value>
  242. [ProtoMember(49)]
  243. public DisplayPreferences DisplayPreferences { get; set; }
  244. /// <summary>
  245. /// Gets or sets the status.
  246. /// </summary>
  247. /// <value>The status.</value>
  248. [ProtoMember(50)]
  249. public SeriesStatus? Status { get; set; }
  250. /// <summary>
  251. /// Gets or sets the air time.
  252. /// </summary>
  253. /// <value>The air time.</value>
  254. [ProtoMember(51)]
  255. public string AirTime { get; set; }
  256. /// <summary>
  257. /// Gets or sets the air days.
  258. /// </summary>
  259. /// <value>The air days.</value>
  260. [ProtoMember(52)]
  261. public List<DayOfWeek> AirDays { get; set; }
  262. /// <summary>
  263. /// Gets or sets the index options.
  264. /// </summary>
  265. /// <value>The index options.</value>
  266. [ProtoMember(54)]
  267. public string[] IndexOptions { get; set; }
  268. /// <summary>
  269. /// Gets or sets the primary image aspect ratio.
  270. /// </summary>
  271. /// <value>The primary image aspect ratio.</value>
  272. [ProtoMember(55)]
  273. public double? PrimaryImageAspectRatio { get; set; }
  274. /// <summary>
  275. /// Gets or sets the artist.
  276. /// </summary>
  277. /// <value>The artist.</value>
  278. [ProtoMember(56)]
  279. public string Artist { get; set; }
  280. /// <summary>
  281. /// Gets or sets the album.
  282. /// </summary>
  283. /// <value>The album.</value>
  284. [ProtoMember(57)]
  285. public string Album { get; set; }
  286. /// <summary>
  287. /// Gets or sets the album artist.
  288. /// </summary>
  289. /// <value>The album artist.</value>
  290. [ProtoMember(58)]
  291. public string AlbumArtist { get; set; }
  292. /// <summary>
  293. /// Gets or sets the media streams.
  294. /// </summary>
  295. /// <value>The media streams.</value>
  296. [ProtoMember(59)]
  297. public List<MediaStream> MediaStreams { get; set; }
  298. /// <summary>
  299. /// Gets or sets the type of the video.
  300. /// </summary>
  301. /// <value>The type of the video.</value>
  302. [ProtoMember(60)]
  303. public VideoType? VideoType { get; set; }
  304. /// <summary>
  305. /// Gets or sets the display type of the media.
  306. /// </summary>
  307. /// <value>The display type of the media.</value>
  308. [ProtoMember(61)]
  309. public string DisplayMediaType { get; set; }
  310. /// <summary>
  311. /// Determines whether the specified type is type.
  312. /// </summary>
  313. /// <param name="type">The type.</param>
  314. /// <returns><c>true</c> if the specified type is type; otherwise, <c>false</c>.</returns>
  315. public bool IsType(Type type)
  316. {
  317. return IsType(type.Name);
  318. }
  319. /// <summary>
  320. /// Determines whether the specified type is type.
  321. /// </summary>
  322. /// <param name="type">The type.</param>
  323. /// <returns><c>true</c> if the specified type is type; otherwise, <c>false</c>.</returns>
  324. public bool IsType(string type)
  325. {
  326. return Type.Equals(type, StringComparison.OrdinalIgnoreCase);
  327. }
  328. /// <summary>
  329. /// Gets or sets the image tags.
  330. /// </summary>
  331. /// <value>The image tags.</value>
  332. [ProtoMember(62)]
  333. public Dictionary<ImageType, Guid> ImageTags { get; set; }
  334. /// <summary>
  335. /// Gets or sets the backdrop image tags.
  336. /// </summary>
  337. /// <value>The backdrop image tags.</value>
  338. [ProtoMember(63)]
  339. public List<Guid> BackdropImageTags { get; set; }
  340. /// <summary>
  341. /// Gets or sets the parent logo image tag.
  342. /// </summary>
  343. /// <value>The parent logo image tag.</value>
  344. [ProtoMember(64)]
  345. public Guid? ParentLogoImageTag { get; set; }
  346. /// <summary>
  347. /// Gets or sets the chapters.
  348. /// </summary>
  349. /// <value>The chapters.</value>
  350. [ProtoMember(65)]
  351. public List<ChapterInfoDto> Chapters { get; set; }
  352. /// <summary>
  353. /// Gets or sets the video format.
  354. /// </summary>
  355. /// <value>The video format.</value>
  356. [ProtoMember(66)]
  357. public VideoFormat? VideoFormat { get; set; }
  358. /// <summary>
  359. /// Gets or sets the type of the location.
  360. /// </summary>
  361. /// <value>The type of the location.</value>
  362. [ProtoMember(67)]
  363. public LocationType LocationType { get; set; }
  364. /// <summary>
  365. /// Gets or sets the type of the iso.
  366. /// </summary>
  367. /// <value>The type of the iso.</value>
  368. [ProtoMember(68)]
  369. public IsoType? IsoType { get; set; }
  370. /// <summary>
  371. /// Gets or sets the type of the media.
  372. /// </summary>
  373. /// <value>The type of the media.</value>
  374. [ProtoMember(69)]
  375. public string MediaType { get; set; }
  376. /// <summary>
  377. /// Gets a value indicating whether this instance can resume.
  378. /// </summary>
  379. /// <value><c>true</c> if this instance can resume; otherwise, <c>false</c>.</value>
  380. [IgnoreDataMember]
  381. public bool CanResume
  382. {
  383. get { return UserData != null && UserData.PlaybackPositionTicks > 0; }
  384. }
  385. /// <summary>
  386. /// Gets the resume position ticks.
  387. /// </summary>
  388. /// <value>The resume position ticks.</value>
  389. [IgnoreDataMember]
  390. public long ResumePositionTicks
  391. {
  392. get { return UserData == null ? 0 : UserData.PlaybackPositionTicks; }
  393. }
  394. /// <summary>
  395. /// Gets the backdrop count.
  396. /// </summary>
  397. /// <value>The backdrop count.</value>
  398. [IgnoreDataMember]
  399. public int BackdropCount
  400. {
  401. get { return BackdropImageTags == null ? 0 : BackdropImageTags.Count; }
  402. }
  403. /// <summary>
  404. /// Gets a value indicating whether this instance has banner.
  405. /// </summary>
  406. /// <value><c>true</c> if this instance has banner; otherwise, <c>false</c>.</value>
  407. [IgnoreDataMember]
  408. public bool HasBanner
  409. {
  410. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Banner); }
  411. }
  412. /// <summary>
  413. /// Gets a value indicating whether this instance has art.
  414. /// </summary>
  415. /// <value><c>true</c> if this instance has art; otherwise, <c>false</c>.</value>
  416. [IgnoreDataMember]
  417. public bool HasArtImage
  418. {
  419. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Art); }
  420. }
  421. /// <summary>
  422. /// Gets a value indicating whether this instance has logo.
  423. /// </summary>
  424. /// <value><c>true</c> if this instance has logo; otherwise, <c>false</c>.</value>
  425. [IgnoreDataMember]
  426. public bool HasLogo
  427. {
  428. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Logo); }
  429. }
  430. /// <summary>
  431. /// Gets a value indicating whether this instance has thumb.
  432. /// </summary>
  433. /// <value><c>true</c> if this instance has thumb; otherwise, <c>false</c>.</value>
  434. [IgnoreDataMember]
  435. public bool HasThumb
  436. {
  437. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Thumb); }
  438. }
  439. /// <summary>
  440. /// Gets a value indicating whether this instance has primary image.
  441. /// </summary>
  442. /// <value><c>true</c> if this instance has primary image; otherwise, <c>false</c>.</value>
  443. [IgnoreDataMember]
  444. public bool HasPrimaryImage
  445. {
  446. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Primary); }
  447. }
  448. /// <summary>
  449. /// Gets a value indicating whether this instance has disc image.
  450. /// </summary>
  451. /// <value><c>true</c> if this instance has disc image; otherwise, <c>false</c>.</value>
  452. [IgnoreDataMember]
  453. public bool HasDiscImage
  454. {
  455. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Disc); }
  456. }
  457. /// <summary>
  458. /// Gets a value indicating whether this instance has box image.
  459. /// </summary>
  460. /// <value><c>true</c> if this instance has box image; otherwise, <c>false</c>.</value>
  461. [IgnoreDataMember]
  462. public bool HasBoxImage
  463. {
  464. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Box); }
  465. }
  466. /// <summary>
  467. /// Gets a value indicating whether this instance has menu image.
  468. /// </summary>
  469. /// <value><c>true</c> if this instance has menu image; otherwise, <c>false</c>.</value>
  470. [IgnoreDataMember]
  471. public bool HasMenuImage
  472. {
  473. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Menu); }
  474. }
  475. /// <summary>
  476. /// Gets a value indicating whether this instance is video.
  477. /// </summary>
  478. /// <value><c>true</c> if this instance is video; otherwise, <c>false</c>.</value>
  479. [IgnoreDataMember]
  480. public bool HasTrailer
  481. {
  482. get { return LocalTrailerCount > 0 || (TrailerUrls != null && TrailerUrls.Count > 0); }
  483. }
  484. /// <summary>
  485. /// Gets a value indicating whether this instance is video.
  486. /// </summary>
  487. /// <value><c>true</c> if this instance is video; otherwise, <c>false</c>.</value>
  488. [IgnoreDataMember]
  489. public bool IsVideo
  490. {
  491. get { return string.Equals(MediaType, Entities.MediaType.Video, StringComparison.OrdinalIgnoreCase); }
  492. }
  493. /// <summary>
  494. /// Gets a value indicating whether this instance is audio.
  495. /// </summary>
  496. /// <value><c>true</c> if this instance is audio; otherwise, <c>false</c>.</value>
  497. [IgnoreDataMember]
  498. public bool IsAudio
  499. {
  500. get { return string.Equals(MediaType, Entities.MediaType.Audio, StringComparison.OrdinalIgnoreCase); }
  501. }
  502. /// <summary>
  503. /// Gets a value indicating whether this instance is game.
  504. /// </summary>
  505. /// <value><c>true</c> if this instance is game; otherwise, <c>false</c>.</value>
  506. [IgnoreDataMember]
  507. public bool IsGame
  508. {
  509. get { return string.Equals(MediaType, Entities.MediaType.Game, StringComparison.OrdinalIgnoreCase); }
  510. }
  511. /// <summary>
  512. /// Gets a value indicating whether this instance is person.
  513. /// </summary>
  514. /// <value><c>true</c> if this instance is person; otherwise, <c>false</c>.</value>
  515. [IgnoreDataMember]
  516. public bool IsPerson
  517. {
  518. get { return string.Equals(Type, "Person", StringComparison.OrdinalIgnoreCase); }
  519. }
  520. /// <summary>
  521. /// Gets a value indicating whether this instance is root.
  522. /// </summary>
  523. /// <value><c>true</c> if this instance is root; otherwise, <c>false</c>.</value>
  524. [IgnoreDataMember]
  525. public bool IsRoot
  526. {
  527. get { return string.Equals(Type, "AggregateFolder", StringComparison.OrdinalIgnoreCase); }
  528. }
  529. /// <summary>
  530. /// Occurs when [property changed].
  531. /// </summary>
  532. public event PropertyChangedEventHandler PropertyChanged;
  533. }
  534. }