Book.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #nullable disable
  2. #pragma warning disable CS1591
  3. using System;
  4. using System.Linq;
  5. using System.Text.Json.Serialization;
  6. using Jellyfin.Data.Enums;
  7. using MediaBrowser.Controller.Providers;
  8. namespace MediaBrowser.Controller.Entities
  9. {
  10. public class Book : BaseItem, IHasLookupInfo<BookInfo>, IHasSeries
  11. {
  12. public Book()
  13. {
  14. this.RunTimeTicks = TimeSpan.TicksPerSecond;
  15. }
  16. [JsonIgnore]
  17. public override MediaType MediaType => MediaType.Book;
  18. public override bool SupportsPlayedStatus => true;
  19. public override bool SupportsPositionTicksResume => true;
  20. [JsonIgnore]
  21. public override bool SupportsPeople => true;
  22. [JsonIgnore]
  23. public string SeriesPresentationUniqueKey { get; set; }
  24. [JsonIgnore]
  25. public string SeriesName { get; set; }
  26. [JsonIgnore]
  27. public Guid SeriesId { get; set; }
  28. public string FindSeriesSortName()
  29. {
  30. return SeriesName;
  31. }
  32. public string FindSeriesName()
  33. {
  34. return SeriesName;
  35. }
  36. public string FindSeriesPresentationUniqueKey()
  37. {
  38. return SeriesPresentationUniqueKey;
  39. }
  40. public Guid FindSeriesId()
  41. {
  42. return SeriesId;
  43. }
  44. /// <inheritdoc />
  45. public override bool CanDownload()
  46. {
  47. return IsFileProtocol;
  48. }
  49. /// <inheritdoc />
  50. public override UnratedItem GetBlockUnratedType()
  51. {
  52. return UnratedItem.Book;
  53. }
  54. public BookInfo GetLookupInfo()
  55. {
  56. var info = GetItemLookupInfo<BookInfo>();
  57. if (string.IsNullOrEmpty(SeriesName))
  58. {
  59. info.SeriesName = GetParents().Select(i => i.Name).FirstOrDefault();
  60. }
  61. else
  62. {
  63. info.SeriesName = SeriesName;
  64. }
  65. return info;
  66. }
  67. }
  68. }