private T GetItemFromMedia <T>(MediaRoot media) where T : BaseItem, new() { if (media == null) { throw new ArgumentNullException(nameof(media)); } var item = new T { Name = media.Title, Overview = Sanitizer.SanitizeDescription(media.Synopsis), ProviderIds = new Dictionary <string, string> { { Name, media.Mal_Id.ToString() }, } }; if (media.Genres?.Count > 0) { item.Genres = media.Genres.Select(i => i.Name).ToArray(); } int?startYear = media.Aired?.From.Year, startMonth = media.Aired?.From.Month, startDay = media.Aired?.From.Day; if (startYear.HasValue && startMonth.HasValue && startDay.HasValue) { item.PremiereDate = new DateTime(startYear.Value, startMonth.Value, startDay.Value); item.ProductionYear = startYear.Value; } item.CommunityRating = (float)Math.Round(media.Score, 1); return(item); }
private void LogMediaFound(MediaRoot media, [CallerMemberName] string caller = null) { _logger.LogCallerInfo($"Media found:", caller); _logger.LogCallerInfo($"{nameof(media.Mal_Id)}: {media.Mal_Id}", caller); _logger.LogCallerInfo($"{nameof(media.Title)}: \"{media.Title}\"", caller); if (media.Genres?.Count > 0) { _logger.LogCallerInfo($"{nameof(media.Genres)}: \"{string.Join(",", media.Genres.Select(i => i.Name))}\"", caller); } else { _logger.LogCallerWarning($"No {nameof(media.Genres)} found", caller); } }
public RemoteSearchResult GetSearchResultFromMedia(MediaRoot media) { if (media == null) { throw new ArgumentNullException(nameof(media)); } return(new RemoteSearchResult { SearchProviderName = Name, Name = media.Title, ImageUrl = media.Image_Url, Overview = Sanitizer.SanitizeDescription(media.Synopsis), ProviderIds = new Dictionary <string, string> { { Name, media.Mal_Id.ToString() } } }); }