using System; using System.Collections.Generic; using System.Diagnostics; using System.Xml.Linq; namespace NzbDrone.Core.MetadataSource.Goodreads { /// /// This class models areas of the API where Goodreads returns /// very brief information about a Book instead of their entire object. /// [DebuggerDisplay("{DebuggerDisplay,nq}")] public sealed class BookSummaryResource : GoodreadsResource { public override string ElementName => "book"; /// /// The Id of this book. /// public long Id { get; private set; } public string Uri { get; set; } /// /// The title of this book. /// public string Title { get; private set; } /// /// The title of this book without series information in it. /// public string TitleWithoutSeries { get; private set; } /// /// The link to the Goodreads page for this book. /// public string Link { get; private set; } /// /// The cover image of this book, regular size. /// public string ImageUrl { get; private set; } /// /// The cover image of this book, small size. /// public string SmallImageUrl { get; private set; } /// /// The work id of this book. /// public long? WorkId { get; private set; } /// /// The ISBN of this book. /// public string Isbn { get; private set; } /// /// The ISBN13 of this book. /// public string Isbn13 { get; private set; } /// /// The average rating of the book. /// public decimal? AverageRating { get; private set; } /// /// The count of all ratings for the book. /// public int? RatingsCount { get; private set; } /// /// The date this book was published. /// public DateTime? PublicationDate { get; private set; } /// /// Summary information about the authors of this book. /// public IReadOnlyList Authors { get; private set; } /// /// The edition information about book. /// public string EditionInformation { get; private set; } /// /// The book format. /// public string Format { get; private set; } /// /// The book description. /// public string Description { get; private set; } /// /// Number of pages. /// public int NumberOfPages { get; private set; } /// /// The book publisher. /// public string Publisher { get; private set; } /// /// The image url, large size. /// public string LargeImageUrl { get; private set; } /// /// A count of text reviews for this book. /// public int TextReviewsCount { get; private set; } public override void Parse(XElement element) { Id = element.ElementAsLong("id"); Uri = element.ElementAsString("uri"); Title = element.ElementAsString("title"); TitleWithoutSeries = element.ElementAsString("title_without_series"); Link = element.ElementAsString("link"); ImageUrl = element.ElementAsString("image_url"); SmallImageUrl = element.ElementAsString("small_image_url"); Isbn = element.ElementAsString("isbn"); Isbn13 = element.ElementAsString("isbn13"); AverageRating = element.ElementAsNullableDecimal("average_rating"); RatingsCount = element.ElementAsNullableInt("ratings_count"); PublicationDate = element.ElementAsMultiDateField("publication"); Authors = element.ParseChildren("authors", "author"); var workElement = element.Element("work"); if (workElement != null) { WorkId = workElement.ElementAsNullableInt("id"); } EditionInformation = element.ElementAsString("edition_information"); Format = element.ElementAsString("format"); Description = element.ElementAsString("description"); NumberOfPages = element.ElementAsInt("num_pages"); Publisher = element.ElementAsString("publisher"); LargeImageUrl = element.ElementAsString("large_image_url"); TextReviewsCount = element.ElementAsInt("text_reviews_count"); } } }