public static Video VideoFromAnimeEpisode(IProvider prov, List <Contract_CrossRef_AniDB_TvDBV2> cross, KeyValuePair <AnimeEpisode, Contract_AnimeEpisode> e, int userid) { Video v = (Video)e.Key.PlexContract?.Clone <Video>(); if (v?.Thumb != null) { v.Thumb = ReplaceSchemeHost(v.Thumb); } if (v != null && (v.Medias == null || v.Medias.Count == 0)) { List <VideoLocal> locals = e.Key.GetVideoLocals(); if (locals.Count > 0) { VideoLocalRepository lrepo = new VideoLocalRepository(); AnimeEpisodeRepository erepo = new AnimeEpisodeRepository(); foreach (VideoLocal n in locals) { lrepo.Save(n, false); } erepo.Save(e.Key); } v = (Video)e.Key.PlexContract?.Clone <Video>(); } if (v != null) { if (e.Value != null) { v.ViewCount = e.Value.WatchedCount.ToString(); if (e.Value.WatchedDate.HasValue) { v.LastViewedAt = e.Value.WatchedDate.Value.ToUnixTime(); } } v.ParentIndex = "1"; if (e.Key.EpisodeTypeEnum != enEpisodeType.Episode) { v.ParentIndex = null; } if (cross != null && cross.Count > 0) { Contract_CrossRef_AniDB_TvDBV2 c2 = cross.FirstOrDefault( a => a.AniDBStartEpisodeType == int.Parse(v.EpisodeType) && a.AniDBStartEpisodeNumber <= int.Parse(v.EpisodeNumber)); if (c2?.TvDBSeasonNumber > 0) { v.ParentIndex = c2.TvDBSeasonNumber.ToString(); } } AddLinksToAnimeEpisodeVideo(prov, v, userid); } return(v); }
public Contract_CrossRef_AniDB_TvDBV2 ToContract() { Contract_CrossRef_AniDB_TvDBV2 contract = new Contract_CrossRef_AniDB_TvDBV2(); contract.CrossRef_AniDB_TvDBV2ID = this.CrossRef_AniDB_TvDBV2ID; contract.AnimeID = this.AnimeID; contract.AniDBStartEpisodeType = this.AniDBStartEpisodeType; contract.AniDBStartEpisodeNumber = this.AniDBStartEpisodeNumber; contract.TvDBID = this.TvDBID; contract.TvDBSeasonNumber = this.TvDBSeasonNumber; contract.TvDBStartEpisodeNumber = this.TvDBStartEpisodeNumber; contract.CrossRefSource = this.CrossRefSource; contract.TvDBTitle = this.TvDBTitle; return(contract); }
private static bool PopulateVideoEpisodeFromAnime(Video v, AnimeEpisode ep, AnimeSeries ser, Contract_AnimeSeries cserie, AniDB_Anime ani, Video nv) { bool ret = false; // v.ParentTitle = "Season 1"; // v.GrandparentTitle = ser.GetSeriesName(); v.ParentIndex = "1"; v.Art = ani.GetDefaultFanartDetailsNoBlanks().GenArt(); if (ep.EpisodeTypeEnum != enEpisodeType.Episode) { //v.ParentTitle = ep.ToString(); v.ParentIndex = null; } else if (cserie.CrossRefAniDBTvDBV2 != null && cserie.CrossRefAniDBTvDBV2.Count > 0) { Contract_CrossRef_AniDB_TvDBV2 c2 = cserie.CrossRefAniDBTvDBV2.FirstOrDefault( a => a.AniDBStartEpisodeType == ep.AniDB_Episode.EpisodeType && a.AniDBStartEpisodeNumber <= ep.AniDB_Episode.EpisodeNumber); if (c2 != null) { // v.ParentTitle = "Season " + c2.TvDBSeasonNumber; if (c2.TvDBSeasonNumber > 0) { v.ParentIndex = c2.TvDBSeasonNumber.ToString(); } } } //v.Title1 = v.GrandparentTitle; //v.Title2 = v.ParentTitle; if (ani != null) { if (ani.Restricted > 0) { v.ContentRating = "R"; } if (ani.AnimeTypeEnum == enAnimeType.Movie) { v.Type = "movie"; if (v.Title.StartsWith("Complete Movie")) { v.Title = nv.Title; v.Summary = nv.Summary; v.Index = null; ret = true; } else if (v.Title.StartsWith("Part ")) { v.Title = nv.Title + " - " + v.Title; v.Summary = nv.Summary; } v.Thumb = nv.Thumb; } else if (ani.AnimeTypeEnum == enAnimeType.OVA) { if (v.Title == "OVA") { v.Title = nv.Title; v.Type = "movie"; v.Thumb = nv.Thumb; v.Summary = nv.Summary; v.Index = null; ret = true; } } // else // v.ParentTitle = nv.Title; } if (string.IsNullOrEmpty(v.Art)) { v.Art = nv.Art; } if (v.Tags == null) { v.Tags = nv.Tags; } if (v.Genres == null) { v.Genres = nv.Genres; } if (v.Roles == null) { v.Roles = nv.Roles; } if (string.IsNullOrEmpty(v.Rating)) { v.Rating = nv.Rating; } v.Index = ep.AniDB_Episode.EpisodeNumber.ToString(); return(ret); }
public static Video VideoFromAnimeEpisode(IProvider prov, List <Contract_CrossRef_AniDB_TvDBV2> cross, KeyValuePair <AnimeEpisode, Contract_AnimeEpisode> e, int userid) { Video v = (Video)e.Key.PlexContract?.Clone <Video>(); if (v?.Thumb != null) { v.Thumb = ReplaceSchemeHost(v.Thumb); } if (v != null && (v.Medias == null || v.Medias.Count == 0)) { foreach (VideoLocal vl2 in e.Key.GetVideoLocals()) { if (string.IsNullOrEmpty(vl2.Media?.Duration)) { VideoLocal_Place pl = vl2.GetBestVideoLocalPlace(); if (pl != null) { if (pl.RefreshMediaInfo()) { RepoFactory.VideoLocal.Save(vl2, true); } } } } RepoFactory.AnimeEpisode.Save(e.Key); v = (Video)e.Key.PlexContract?.Clone <Video>(); } if (v != null) { if (e.Value != null) { v.ViewCount = e.Value.WatchedCount.ToString(); if (e.Value.WatchedDate.HasValue) { v.LastViewedAt = e.Value.WatchedDate.Value.ToUnixTime(); } } v.ParentIndex = "1"; if (e.Key.EpisodeTypeEnum != enEpisodeType.Episode) { v.ParentIndex = null; } if (cross != null && cross.Count > 0) { Contract_CrossRef_AniDB_TvDBV2 c2 = cross.FirstOrDefault( a => a.AniDBStartEpisodeType == int.Parse(v.EpisodeType) && a.AniDBStartEpisodeNumber <= int.Parse(v.EpisodeNumber)); if (c2?.TvDBSeasonNumber > 0) { v.ParentIndex = c2.TvDBSeasonNumber.ToString(); } } AddLinksToAnimeEpisodeVideo(prov, v, userid); } v.AddResumePosition(prov, userid); return(v); }