public static AnimeTitle CopyTo(this AnimeTitle v, AnimeTitle o) { o.Type = v.Type; o.Language = v.Language; o.Title = v.Title; return(o); }
public static string GetTitle(this AnimeTitle title) { var titles = new List <string>(); if (!string.IsNullOrWhiteSpace(title.Romaji)) { titles.Add(title.Romaji); } if (!string.IsNullOrWhiteSpace(title.English)) { titles.Add(title.English); } if (!string.IsNullOrWhiteSpace(title.Native)) { titles.Add(title.Native); } return(string.Join(" | ", titles)); }
public static Serie GenerateFromAnimeSeries(NancyContext ctx, SVR_AnimeSeries ser, int uid, bool nocast, bool notag, int level, bool all, bool allpics, int pic, TagFilter.Filter tagfilter) { Serie sr = GenerateFromAniDB_Anime(ctx, ser.GetAnime(), nocast, notag, allpics, pic, tagfilter); List <SVR_AnimeEpisode> ael = ser.GetAnimeEpisodes(); var contract = ser.Contract; if (contract == null) { ser.UpdateContract(); } sr.id = ser.AnimeSeriesID; sr.name = ser.GetSeriesName(); GenerateSizes(sr, ael, uid); int?season = ael.FirstOrDefault(a => a.AniDB_Episode.EpisodeType == (int)EpisodeType.Episode && a.AniDB_Episode.EpisodeNumber == 1) ?.TvDBEpisode?.SeasonNumber; if (season != null) { sr.season = season.Value.ToString(); } var tvdbseriesID = ael.Select(a => a.TvDBEpisode).Where(a => a != null).GroupBy(a => a.SeriesID) .MaxBy(a => a.Count()).FirstOrDefault()?.Key; if (tvdbseriesID != null) { var tvdbseries = RepoFactory.TvDB_Series.GetByTvDBID(tvdbseriesID.Value); if (tvdbseries != null) { var title = new AnimeTitle { Language = "EN", Title = tvdbseries.SeriesName, Type = "TvDB" }; sr.titles.Add(title); } } if (level > 0) { if (ael.Count > 0) { sr.eps = new List <Episode>(); foreach (SVR_AnimeEpisode ae in ael) { if (!all && (ae?.GetVideoLocals()?.Count ?? 0) == 0) { continue; } Episode new_ep = Episode.GenerateFromAnimeEpisode(ctx, ae, uid, (level - 1), pic); if (new_ep == null) { continue; } sr.eps.Add(new_ep); if (level - 1 <= 0) { continue; } foreach (RawFile file in new_ep.files) { sr.filesize += file.size; } } sr.eps = sr.eps.OrderBy(a => a.epnumber).ToList(); } } return(sr); }
public static Video GenerateFromAnimeGroup(ISession session, AnimeGroup grp, int userid, List <AnimeSeries> allSeries) { Contract_AnimeGroup cgrp = grp.GetUserContract(userid); int subgrpcnt = grp.GetAllChildGroups().Count; if ((cgrp.Stat_SeriesCount == 1) && (subgrpcnt == 0)) { AnimeSeries ser = JMMServiceImplementation.GetSeriesForGroup(grp.AnimeGroupID, allSeries); if (ser != null) { Contract_AnimeSeries cserie = ser.GetUserContract(userid); if (cserie != null) { Video v = GenerateFromSeries(cserie, ser, ser.GetAnime(session), userid); v.AirDate = ser.AirDate; v.UpdatedAt = ser.LatestEpisodeAirDate.HasValue ? ser.LatestEpisodeAirDate.Value.ToUnixTime() : null; v.Group = cgrp; return(v); } } } else { AnimeSeries ser = grp.DefaultAnimeSeriesID.HasValue ? allSeries.FirstOrDefault(a => a.AnimeSeriesID == grp.DefaultAnimeSeriesID.Value) : allSeries.Find(a => a.AirDate != DateTime.MinValue); if ((ser == null) && (allSeries != null && allSeries.Count > 0)) { ser = allSeries[0]; } Contract_AnimeSeries cserie = ser?.GetUserContract(userid); Video v = FromGroup(cgrp, cserie, userid, subgrpcnt); v.Group = cgrp; v.AirDate = cgrp.Stat_AirDate_Min ?? DateTime.MinValue; v.UpdatedAt = cgrp.LatestEpisodeAirDate?.ToUnixTime(); v.Rating = "" + Math.Round((grp.AniDBRating / 100), 1); List <Tag> newTags = new List <Tag>(); foreach (AniDB_Tag tag in grp.Tags) { Tag newTag = new Tag(); TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; newTag.Value = textInfo.ToTitleCase(tag.TagName.Trim()); if (!newTags.Contains(newTag)) { newTags.Add(newTag); } } v.Genres = newTags; if (ser != null) { List <AnimeTitle> newTitles = new List <AnimeTitle>(); foreach (AniDB_Anime_Title title in ser.GetAnime(session).GetTitles()) { AnimeTitle newTitle = new AnimeTitle(); newTitle.Title = title.Title; newTitle.Language = title.Language; newTitle.Type = title.TitleType; newTitles.Add(newTitle); } v.Titles = newTitles; v.Roles = new List <RoleTag>(); //TODO Character implementation is limited in JMM, One Character, could have more than one Seiyuu if (ser.GetAnime(session).Contract?.AniDBAnime?.Characters != null) { foreach (Contract_AniDB_Character c in ser.GetAnime(session).Contract.AniDBAnime.Characters) { string ch = c?.CharName; Contract_AniDB_Seiyuu seiyuu = c?.Seiyuu; if (!string.IsNullOrEmpty(ch)) { RoleTag t = new RoleTag(); t.Value = seiyuu?.SeiyuuName; if (seiyuu != null) { t.TagPicture = Helper.ConstructSeiyuuImage(seiyuu.AniDB_SeiyuuID); } t.Role = ch; t.RoleDescription = c?.CharDescription; t.RolePicture = Helper.ConstructCharacterImage(c.CharID); v.Roles.Add(t); } } } } return(v); } return(null); }