예제 #1
0
        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);
        }
예제 #2
0
        public void CreateAnimeEpisode(ISession session, int animeSeriesID)
        {
            // check if there is an existing episode for this EpisodeID
            AnimeEpisodeRepository repEps     = new AnimeEpisodeRepository();
            AnimeEpisode           existingEp = repEps.GetByAniDBEpisodeID(session, EpisodeID);

            if (existingEp == null)
            {
                AnimeEpisode animeEp = new AnimeEpisode();
                animeEp.Populate(this);
                animeEp.AnimeSeriesID = animeSeriesID;
                repEps.Save(session, animeEp);
            }
        }