private AnimeDTO MapAnime(AnimeDataModel model) { var anime = model.Attributes; if (!IsProcessable(model.Id, anime)) { return(null); } var status = EnumHelper.GetEnumFromString <EAnimeStatus>(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(anime.Status)); DateTime.TryParseExact(anime.StartDate, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime startDate); var endDateCorrect = DateTime.TryParseExact(anime.EndDate, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime endDate); return(new AnimeDTO { KitsuID = int.Parse(model.Id), Slug = anime.Slug, Name = anime.CanonicalTitle, Synopsis = anime.Synopsis, Status = status.Value, StartDate = startDate, EndDate = endDateCorrect ? endDate : (DateTime?)null, Season = EnumHelper.GetSeason(startDate.Month), CoverImageUrl = GetBaseUrl(model.Id, anime.CoverImage?.Original), PosterImageUrl = GetBaseUrl(model.Id, anime.PosterImage?.Original), }); }
public static EmbedBuilder ToEmbed(this AnimeDataModel model, ResourceManager loc) { var attr = model.Attributes; var embed = new EmbedBuilder() .WithColor(Color.Purple) .WithImageUrl(attr.PosterImage.Large) .WithTitle(attr.CanonicalTitle.CheckEmptyWithLocale(loc)); if (attr.AbbreviatedTitles != null && attr.AbbreviatedTitles.Any()) { embed.AddInlineField(loc.GetString("SKULD_SEARCH_WEEB_SYNON"), attr.AbbreviatedTitles.CheckEmptyWithLocale(", ", loc)); } embed.AddInlineField(loc.GetString("SKULD_SEARCH_WEEB_EPS"), attr.EpisodeCount.CheckEmptyWithLocale(loc)); embed.AddInlineField(loc.GetString("SKULD_SEARCH_WEEB_SDATE"), attr.StartDate.CheckEmptyWithLocale(loc)); embed.AddInlineField(loc.GetString("SKULD_SEARCH_WEEB_EDATE"), attr.EndDate.CheckEmptyWithLocale(loc)); embed.AddInlineField(loc.GetString("SKULD_SEARCH_WEEB_SCORE"), attr.RatingRank.CheckEmptyWithLocale(loc)); if (attr.Synopsis.CheckEmptyWithLocale(loc) != loc.GetString("SKULD_GENERIC_EMPTY")) { var syno = attr.Synopsis; if (syno.Length > 1024) { embed.AddInlineField(loc.GetString("SKULD_SEARCH_WEEB_SYNOP"), attr.Synopsis.Substring(0, 1021) + "..."); } else { embed.AddInlineField(loc.GetString("SKULD_SEARCH_WEEB_SYNOP"), attr.Synopsis); } } return(embed); }