BaseItemDto.cs 20 KB

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