Exemplo n.º 1
0
        public static Video VideoFromAnimeEpisode(IProvider prov, List <CrossRef_AniDB_TvDBV2> cross,
                                                  KeyValuePair <SVR_AnimeEpisode, CL_AnimeEpisode_User> e, int userid)
        {
            Video v = GenerateVideoFromAnimeEpisode(e.Key, e.Value.JMMUserID);

            if (v?.Thumb != null)
            {
                v.Thumb = prov.ReplaceSchemeHost(v.Thumb);
            }
            if (v != null)
            {
                if (e.Key.AniDB_Episode == null)
                {
                    return(v);
                }
                if (e.Value != null)
                {
                    v.ViewCount = e.Value.WatchedCount;
                    if (e.Value.WatchedDate.HasValue)
                    {
                        v.LastViewedAt = e.Value.WatchedDate.Value.ToUnixTime();
                    }
                }
                v.ParentIndex = 1;
                if (e.Key.EpisodeTypeEnum != EpisodeType.Episode)
                {
                    v.ParentIndex = 0;
                }

                if (e.Key.EpisodeTypeEnum == EpisodeType.Episode)
                {
                    string client = prov.GetPlexClient().Product;
                    if (client == "Plex for Windows" || client == "Plex Home Theater")
                    {
                        v.Title = $"{v.EpisodeNumber}. {v.Title}";
                    }
                }

                if (cross != null && cross.Count > 0)
                {
                    CrossRef_AniDB_TvDBV2 c2 =
                        cross.FirstOrDefault(
                            a =>
                            a.AniDBStartEpisodeType == v.EpisodeType &&
                            a.AniDBStartEpisodeNumber <= v.EpisodeNumber);
                    if (c2?.TvDBSeasonNumber > 0)
                    {
                        v.ParentIndex = c2.TvDBSeasonNumber;
                    }
                }
                AddLinksToAnimeEpisodeVideo(prov, v, userid);
            }
            v.AddResumePosition(prov, userid);

            return(v);
        }
Exemplo n.º 2
0
        public static Video VideoFromAnimeEpisode(IProvider prov, List <CL_CrossRef_AniDB_Provider> cross, KeyValuePair <SVR_AnimeEpisode, CL_AnimeEpisode_User> e, int userid)
        {
            Video v = e.Key.PlexContract?.Clone <Video>(prov);

            if (v?.Thumb != null)
            {
                v.Thumb = prov.ReplaceSchemeHost(v.Thumb);
            }
            if (v != null && (v.Medias == null || v.Medias.Count == 0))
            {
                using (var upd = Repo.Instance.AnimeEpisode.BeginAddOrUpdate(e.Key))
                {
                    foreach (SVR_VideoLocal vl2 in upd.Entity.GetVideoLocals())
                    {
                        if (vl2.Media?.Duration != 0)
                        {
                            continue;
                        }
                        SVR_VideoLocal_Place pl = vl2.GetBestVideoLocalPlace();

                        if (pl != null)
                        {
                            using (var upd2 = Repo.Instance.VideoLocal.BeginAddOrUpdate(vl2))
                            {
                                if (pl.RefreshMediaInfo(upd2.Entity))
                                {
                                    upd2.Commit(true);
                                }
                            }
                        }
                    }
                    upd.Commit();
                }
                v = e.Key.PlexContract?.Clone <Video>(prov);
            }
            if (v != null)
            {
                if (e.Key.AniDB_Episode == null)
                {
                    return(v);
                }
                if (e.Value != null)
                {
                    v.ViewCount = e.Value.WatchedCount;
                    if (e.Value.WatchedDate.HasValue)
                    {
                        v.LastViewedAt = e.Value.WatchedDate.Value.ToUnixTime();
                    }
                }
                v.ParentIndex = 1;
                if (e.Key.EpisodeTypeEnum != EpisodeType.Episode)
                {
                    v.ParentIndex = 0;
                }

                if (e.Key.EpisodeTypeEnum == EpisodeType.Episode)
                {
                    string client = prov.GetPlexClient().Product;
                    if (client == "Plex for Windows" || client == "Plex Home Theater")
                    {
                        v.Title = $"{v.EpisodeNumber}. {v.Title}";
                    }
                }

                if (cross != null && cross.Count > 0)
                {
                    CrossRef_AniDB_ProviderEpisode ep = cross.Select(a => a.GetEpisodesWithOverrides().FirstOrDefault(b => b.AniDBEpisodeID == e.Key.AniDB_EpisodeID)).FirstOrDefault(a => a != null);
                    if (ep != null && ep.Season > 0)
                    {
                        v.ParentIndex = ep.Season;
                    }
                }
                AddLinksToAnimeEpisodeVideo(prov, v, userid);
            }
            v.AddResumePosition(prov, userid);

            return(v);
        }
Exemplo n.º 3
0
        public static Video VideoFromAnimeEpisode(IProvider prov, List <CrossRef_AniDB_TvDBV2> cross,
                                                  KeyValuePair <SVR_AnimeEpisode, CL_AnimeEpisode_User> e, int userid)
        {
            Video v = e.Key.PlexContract?.Clone <Video>(prov);

            if (v?.Thumb != null)
            {
                v.Thumb = prov.ReplaceSchemeHost(v.Thumb);
            }
            if (v != null && (v.Medias == null || v.Medias.Count == 0))
            {
                foreach (SVR_VideoLocal vl2 in e.Key.GetVideoLocals())
                {
                    if (!string.IsNullOrEmpty(vl2.Media?.Duration))
                    {
                        continue;
                    }
                    SVR_VideoLocal_Place pl = vl2.GetBestVideoLocalPlace();
                    if (pl?.RefreshMediaInfo() == true)
                    {
                        RepoFactory.VideoLocal.Save(vl2, true);
                    }
                }
                RepoFactory.AnimeEpisode.Save(e.Key);
                v = e.Key.PlexContract?.Clone <Video>(prov);
            }
            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 (e.Key.EpisodeTypeEnum == enEpisodeType.Episode)
                {
                    string client = prov.GetPlexClient().Product;
                    if (client == "Plex for Windows" || client == "Plex Home Theater")
                    {
                        v.Title = $"{v.EpisodeNumber}. {v.Title}";
                    }
                }

                if (cross != null && cross.Count > 0)
                {
                    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);
        }
Exemplo n.º 4
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))
            {
                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);
        }