/// <summary> /// /// </summary> /// <param name="item"></param> /// <param name="bookResult"></param> /// <param name="cancellationToken"></param> /// <returns></returns> private async Task ProcessBookImage(BaseItem item, BookResult bookResult, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); string imageUrl = null; if (!string.IsNullOrEmpty(bookResult.volumeInfo.imageLinks.large)) imageUrl = bookResult.volumeInfo.imageLinks.large; else if (!string.IsNullOrEmpty(bookResult.volumeInfo.imageLinks.medium)) imageUrl = bookResult.volumeInfo.imageLinks.medium; else if (!string.IsNullOrEmpty(bookResult.volumeInfo.imageLinks.small)) imageUrl = bookResult.volumeInfo.imageLinks.small; if (!string.IsNullOrEmpty(imageUrl)) await _providerManager.SaveImage(item, bookResult.volumeInfo.imageLinks.large, Plugin.Instance.GoogleBooksSemiphore, ImageType.Primary, null, cancellationToken).ConfigureAwait(false); }
/// <summary> /// /// </summary> /// <param name="item"></param> /// <param name="bookResult"></param> /// <param name="cancellationToken"></param> /// <returns></returns> private void ProcessBookData(BaseItem item, BookResult bookResult, CancellationToken cancellationToken) { var book = item as Book; cancellationToken.ThrowIfCancellationRequested(); book.Name = bookResult.volumeInfo.title; book.Overview = bookResult.volumeInfo.description; try { book.ProductionYear = bookResult.volumeInfo.publishedDate.Length > 4 ? Convert.ToInt32(bookResult.volumeInfo.publishedDate.Substring(0, 4)) : Convert.ToInt32(bookResult.volumeInfo.publishedDate); } catch (Exception e) { _logger.ErrorException("Error parsing date", e); } if (!string.IsNullOrEmpty(bookResult.volumeInfo.publisher)) book.Studios.Add(bookResult.volumeInfo.publisher); if (!string.IsNullOrEmpty(bookResult.volumeInfo.mainCatagory)) book.Tags.Add(bookResult.volumeInfo.mainCatagory); if (bookResult.volumeInfo.catagories != null && bookResult.volumeInfo.catagories.Count > 0) { foreach (var catagory in bookResult.volumeInfo.catagories) book.Tags.Add(catagory); } book.CommunityRating = bookResult.volumeInfo.averageRating * 2; // Google rates out of 5, not 10 if (!string.IsNullOrEmpty(bookResult.id)) book.SetProviderId("GoogleBooks", bookResult.id); }