BaseItemDto.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  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.
  234. /// </summary>
  235. /// <value>The display preferences.</value>
  236. [ProtoMember(49)]
  237. public DisplayPreferences DisplayPreferences { 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 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 the backdrop count.
  390. /// </summary>
  391. /// <value>The backdrop count.</value>
  392. [IgnoreDataMember]
  393. public int BackdropCount
  394. {
  395. get { return BackdropImageTags == null ? 0 : BackdropImageTags.Count; }
  396. }
  397. /// <summary>
  398. /// Gets a value indicating whether this instance has banner.
  399. /// </summary>
  400. /// <value><c>true</c> if this instance has banner; otherwise, <c>false</c>.</value>
  401. [IgnoreDataMember]
  402. public bool HasBanner
  403. {
  404. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Banner); }
  405. }
  406. /// <summary>
  407. /// Gets a value indicating whether this instance has art.
  408. /// </summary>
  409. /// <value><c>true</c> if this instance has art; otherwise, <c>false</c>.</value>
  410. [IgnoreDataMember]
  411. public bool HasArtImage
  412. {
  413. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Art); }
  414. }
  415. /// <summary>
  416. /// Gets a value indicating whether this instance has logo.
  417. /// </summary>
  418. /// <value><c>true</c> if this instance has logo; otherwise, <c>false</c>.</value>
  419. [IgnoreDataMember]
  420. public bool HasLogo
  421. {
  422. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Logo); }
  423. }
  424. /// <summary>
  425. /// Gets a value indicating whether this instance has thumb.
  426. /// </summary>
  427. /// <value><c>true</c> if this instance has thumb; otherwise, <c>false</c>.</value>
  428. [IgnoreDataMember]
  429. public bool HasThumb
  430. {
  431. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Thumb); }
  432. }
  433. /// <summary>
  434. /// Gets a value indicating whether this instance has primary image.
  435. /// </summary>
  436. /// <value><c>true</c> if this instance has primary image; otherwise, <c>false</c>.</value>
  437. [IgnoreDataMember]
  438. public bool HasPrimaryImage
  439. {
  440. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Primary); }
  441. }
  442. /// <summary>
  443. /// Gets a value indicating whether this instance has disc image.
  444. /// </summary>
  445. /// <value><c>true</c> if this instance has disc image; otherwise, <c>false</c>.</value>
  446. [IgnoreDataMember]
  447. public bool HasDiscImage
  448. {
  449. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Disc); }
  450. }
  451. /// <summary>
  452. /// Gets a value indicating whether this instance has box image.
  453. /// </summary>
  454. /// <value><c>true</c> if this instance has box image; otherwise, <c>false</c>.</value>
  455. [IgnoreDataMember]
  456. public bool HasBoxImage
  457. {
  458. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Box); }
  459. }
  460. /// <summary>
  461. /// Gets a value indicating whether this instance has menu image.
  462. /// </summary>
  463. /// <value><c>true</c> if this instance has menu image; otherwise, <c>false</c>.</value>
  464. [IgnoreDataMember]
  465. public bool HasMenuImage
  466. {
  467. get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Menu); }
  468. }
  469. /// <summary>
  470. /// Gets a value indicating whether this instance is video.
  471. /// </summary>
  472. /// <value><c>true</c> if this instance is video; otherwise, <c>false</c>.</value>
  473. [IgnoreDataMember]
  474. public bool HasTrailer
  475. {
  476. get { return LocalTrailerCount > 0 || (TrailerUrls != null && TrailerUrls.Count > 0); }
  477. }
  478. /// <summary>
  479. /// Gets a value indicating whether this instance is video.
  480. /// </summary>
  481. /// <value><c>true</c> if this instance is video; otherwise, <c>false</c>.</value>
  482. [IgnoreDataMember]
  483. public bool IsVideo
  484. {
  485. get { return string.Equals(MediaType, Entities.MediaType.Video, StringComparison.OrdinalIgnoreCase); }
  486. }
  487. /// <summary>
  488. /// Gets a value indicating whether this instance is audio.
  489. /// </summary>
  490. /// <value><c>true</c> if this instance is audio; otherwise, <c>false</c>.</value>
  491. [IgnoreDataMember]
  492. public bool IsAudio
  493. {
  494. get { return string.Equals(MediaType, Entities.MediaType.Audio, StringComparison.OrdinalIgnoreCase); }
  495. }
  496. /// <summary>
  497. /// Gets a value indicating whether this instance is game.
  498. /// </summary>
  499. /// <value><c>true</c> if this instance is game; otherwise, <c>false</c>.</value>
  500. [IgnoreDataMember]
  501. public bool IsGame
  502. {
  503. get { return string.Equals(MediaType, Entities.MediaType.Game, StringComparison.OrdinalIgnoreCase); }
  504. }
  505. /// <summary>
  506. /// Gets a value indicating whether this instance is person.
  507. /// </summary>
  508. /// <value><c>true</c> if this instance is person; otherwise, <c>false</c>.</value>
  509. [IgnoreDataMember]
  510. public bool IsPerson
  511. {
  512. get { return string.Equals(Type, "Person", StringComparison.OrdinalIgnoreCase); }
  513. }
  514. /// <summary>
  515. /// Gets a value indicating whether this instance is root.
  516. /// </summary>
  517. /// <value><c>true</c> if this instance is root; otherwise, <c>false</c>.</value>
  518. [IgnoreDataMember]
  519. public bool IsRoot
  520. {
  521. get { return string.Equals(Type, "AggregateFolder", StringComparison.OrdinalIgnoreCase); }
  522. }
  523. /// <summary>
  524. /// Occurs when [property changed].
  525. /// </summary>
  526. public event PropertyChangedEventHandler PropertyChanged;
  527. }
  528. }