Book.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using MediaBrowser.Controller.Providers;
  2. using MediaBrowser.Model.Configuration;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using MediaBrowser.Model.Entities;
  6. using MediaBrowser.Model.Users;
  7. namespace MediaBrowser.Controller.Entities
  8. {
  9. public class Book : BaseItem, IHasTags, IHasPreferredMetadataLanguage, IHasLookupInfo<BookInfo>, IHasSeries
  10. {
  11. public override string MediaType
  12. {
  13. get
  14. {
  15. return Model.Entities.MediaType.Book;
  16. }
  17. }
  18. /// <summary>
  19. /// Gets or sets the tags.
  20. /// </summary>
  21. /// <value>The tags.</value>
  22. public List<string> Tags { get; set; }
  23. public string SeriesName { get; set; }
  24. public string PreferredMetadataLanguage { get; set; }
  25. /// <summary>
  26. /// Gets or sets the preferred metadata country code.
  27. /// </summary>
  28. /// <value>The preferred metadata country code.</value>
  29. public string PreferredMetadataCountryCode { get; set; }
  30. public Book()
  31. {
  32. Tags = new List<string>();
  33. }
  34. public override bool CanDownload()
  35. {
  36. var locationType = LocationType;
  37. return locationType != LocationType.Remote &&
  38. locationType != LocationType.Virtual;
  39. }
  40. protected override bool GetBlockUnratedValue(UserPolicy config)
  41. {
  42. return config.BlockUnratedItems.Contains(UnratedItem.Book);
  43. }
  44. public BookInfo GetLookupInfo()
  45. {
  46. var info = GetItemLookupInfo<BookInfo>();
  47. if (string.IsNullOrEmpty(SeriesName))
  48. {
  49. info.SeriesName = Parents.Select(i => i.Name).FirstOrDefault();
  50. }
  51. else
  52. {
  53. info.SeriesName = SeriesName;
  54. }
  55. return info;
  56. }
  57. }
  58. }