Ejemplo n.º 1
0
 public static void Init()
 {
     JMMUser.Populate(a => a.JMMUserID);
     CloudAccount.Populate(a => a.CloudID);
     ImportFolder.Populate(a => a.ImportFolderID);
     AniDB_Anime.Populate(a => a.AniDB_AnimeID);
     AniDB_Episode.Populate(a => a.AniDB_EpisodeID);
     AniDB_File.Populate(a => a.AniDB_FileID);
     AniDB_Anime_Title.Populate(a => a.AniDB_Anime_TitleID);
     AniDB_Anime_Tag.Populate(a => a.AniDB_Anime_TagID);
     AniDB_Tag.Populate(a => a.AniDB_TagID);
     CustomTag.Populate(a => a.CustomTagID);
     CrossRef_CustomTag.Populate(a => a.CrossRef_CustomTagID);
     CrossRef_File_Episode.Populate(a => a.CrossRef_File_EpisodeID);
     VideoLocalPlace.Populate(a => a.VideoLocal_Place_ID);
     VideoLocal.Populate(a => a.VideoLocalID);
     VideoLocalUser.Populate(a => a.VideoLocal_UserID);
     GroupFilter.Populate(a => a.GroupFilterID);
     AnimeEpisode.Populate(a => a.AnimeEpisodeID);
     AnimeEpisode_User.Populate(a => a.AnimeEpisode_UserID);
     AnimeSeries.Populate(a => a.AnimeSeriesID);
     AnimeSeries_User.Populate(a => a.AnimeSeries_UserID);
     AnimeGroup.Populate(a => a.AnimeGroupID);
     AnimeGroup_User.Populate(a => a.AnimeGroup_UserID);
     GroupFilter.PostProcess();
     CleanUpMemory();
 }
Ejemplo n.º 2
0
        private static void PopulateVideoEpisodeFromAnimeEpisode(Video v, AnimeEpisode ep, int userid)
        {
            AniDB_Episode aep = ep.AniDB_Episode;

            if (aep != null)
            {
                v.EpNumber      = aep.EpisodeNumber;
                v.Index         = aep.EpisodeNumber.ToString();
                v.Title         = aep.EnglishName;
                v.OriginalTitle = aep.RomajiName;
                v.Rating        = (float.Parse(aep.Rating, CultureInfo.InvariantCulture)).ToString(CultureInfo.InvariantCulture);
                if (aep.AirDateAsDate.HasValue)
                {
                    v.Year = aep.AirDateAsDate.Value.Year.ToString();
                    v.OriginallyAvailableAt = aep.AirDateAsDate.Value.ToPlexDate();
                }
                AnimeEpisode_User epuser = ep.GetUserRecord(userid);
                if (epuser != null)
                {
                    v.ViewCount = epuser.WatchedCount.ToString();
                    if (epuser.WatchedDate.HasValue)
                    {
                        v.LastViewedAt = epuser.WatchedDate.Value.ToUnixTime();
                    }
                }
                MetroContract_Anime_Episode contract = new MetroContract_Anime_Episode();
                JMMServiceImplementationMetro.SetTvDBInfo(aep.AnimeID, aep, ref contract);
                v.Thumb   = contract.GenPoster();
                v.Summary = contract.EpisodeOverview;
            }
        }
        public string RemoveLinkAniDBTvDBEpisode(int aniDBEpisodeID, int tvDBEpisodeID)
        {
            try
            {
                AniDB_Episode ep = RepoFactory.AniDB_Episode.GetByEpisodeID(aniDBEpisodeID);

                if (ep == null)
                {
                    return("Could not find Episode");
                }

                CrossRef_AniDB_TvDB_Episode_Override xref =
                    RepoFactory.CrossRef_AniDB_TvDB_Episode_Override.GetByAniDBAndTvDBEpisodeIDs(aniDBEpisodeID,
                                                                                                 tvDBEpisodeID);
                if (xref == null)
                {
                    return("Could not find Link!");
                }


                RepoFactory.CrossRef_AniDB_TvDB_Episode_Override.Delete(xref.CrossRef_AniDB_TvDB_Episode_OverrideID);

                return(string.Empty);
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.ToString());
                return(ex.Message);
            }
        }
Ejemplo n.º 4
0
        public static void CreateAnimeEpisode(this AniDB_Episode episode, ISession session, int animeSeriesID)
        {
            // check if there is an existing episode for this EpisodeID
            SVR_AnimeEpisode existingEp = RepoFactory.AnimeEpisode.GetByAniDBEpisodeID(episode.EpisodeID);

            if (existingEp == null)
            {
                SVR_AnimeEpisode animeEp = new SVR_AnimeEpisode();
                animeEp.Populate(episode);
                animeEp.AnimeSeriesID = animeSeriesID;
                RepoFactory.AnimeEpisode.Save(animeEp);
            }
            else
            {
                if (existingEp.AnimeSeriesID != animeSeriesID)
                {
                    existingEp.AnimeSeriesID = animeSeriesID;
                }
                existingEp.PlexContract = null;
                RepoFactory.AnimeEpisode.Save(existingEp);
                foreach (var episodeUser in RepoFactory.AnimeEpisode_User.GetByEpisodeID(existingEp.AnimeEpisodeID))
                {
                    RepoFactory.AnimeEpisode_User.SaveWithOpenTransaction(session, episodeUser);
                }
            }
        }
Ejemplo n.º 5
0
        public string RemoveLinkAniDBTraktEpisode(int aniDBEpisodeID, string traktEpisodeID)
        {
            try
            {
                AniDB_Episode ep = Repo.Instance.AniDB_Episode.GetByEpisodeID(aniDBEpisodeID);

                if (ep == null)
                {
                    return("Could not find Episode");
                }

                using (var upd = Repo.Instance.CrossRef_AniDB_Provider.BeginAddOrUpdate(() => Repo.Instance.CrossRef_AniDB_Provider.GetByAnimeIDAndType(ep.AnimeID, CrossRefType.TraktTV).FirstOrDefault(a => a.EpisodesListOverride.GetByProviderId(traktEpisodeID) != null)))
                {
                    if (!upd.IsUpdate)
                    {
                        return("Could not find Link!");
                    }
                    upd.Entity.EpisodesListOverride.DeleteFromProviderEpisodeId(traktEpisodeID);
                    if (upd.Entity.EpisodesListOverride.NeedPersitance)
                    {
                        upd.Commit();
                    }
                }
                return(string.Empty);
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.ToString());
                return(ex.Message);
            }
        }
Ejemplo n.º 6
0
            public AniDB(AniDB_Episode ep)
            {
                if (!decimal.TryParse(ep.Rating, out var rating))
                {
                    rating = 0;
                }
                if (!int.TryParse(ep.Votes, out var votes))
                {
                    votes = 0;
                }
                var titles = RepoFactory.AniDB_Episode_Title.GetByEpisodeID(ep.EpisodeID);

                ID            = ep.EpisodeID;
                Type          = MapAniDBEpisodeType(ep.GetEpisodeTypeEnum());
                EpisodeNumber = ep.EpisodeNumber;
                AirDate       = ep.GetAirDateAsDate();
                Description   = ep.Description;
                Rating        = new Rating
                {
                    MaxValue = 10,
                    Value    = rating,
                    Votes    = votes,
                    Source   = "AniDB",
                };
                Titles = titles.Select(a => new Title
                {
                    Name     = a.Title,
                    Language = a.Language.ToLower(),
                    Default  = false,
                    Source   = "AniDB",
                }
                                       ).ToList();
            }
Ejemplo n.º 7
0
        public static void Init()
        {
            JMMUser.Populate();
            CloudAccount.Populate();
            ImportFolder.Populate();
            AniDB_Anime.Populate();
            AniDB_Episode.Populate();
            AniDB_File.Populate();
            AniDB_Anime_Title.Populate();
            AniDB_Anime_Tag.Populate();
            AniDB_Tag.Populate();
            CustomTag.Populate();
            CrossRef_CustomTag.Populate();
            CrossRef_File_Episode.Populate();
            VideoLocalPlace.Populate();
            VideoLocal.Populate();
            VideoLocalUser.Populate();
            GroupFilter.Populate();
            AnimeEpisode.Populate();
            AnimeEpisode_User.Populate();
            AnimeSeries.Populate();
            AnimeSeries_User.Populate();
            AnimeGroup.Populate();
            AnimeGroup_User.Populate();

            // Update Contracts if necessary
            try
            {
                JMMUser.RegenerateDb();
                CloudAccount.RegenerateDb();
                ImportFolder.RegenerateDb();
                AniDB_Anime.RegenerateDb();
                AniDB_Episode.RegenerateDb();
                AniDB_File.RegenerateDb();
                AniDB_Anime_Title.RegenerateDb();
                AniDB_Anime_Tag.RegenerateDb();
                AniDB_Tag.RegenerateDb();
                CustomTag.RegenerateDb();
                CrossRef_CustomTag.RegenerateDb();
                CrossRef_File_Episode.RegenerateDb();
                VideoLocalPlace.RegenerateDb();
                VideoLocal.RegenerateDb();
                VideoLocalUser.RegenerateDb();
                AnimeEpisode.RegenerateDb();
                AnimeEpisode_User.RegenerateDb();
                AnimeSeries.RegenerateDb();
                AnimeSeries_User.RegenerateDb();
                AnimeGroup.RegenerateDb();
                AnimeGroup_User.RegenerateDb();

                GroupFilter.RegenerateDb();
                GroupFilter.PostProcess();
            }
            catch (Exception e)
            {
                LogManager.GetCurrentClassLogger().Error(e, "There was an error starting the Database Factory");
            }
            CleanUpMemory();
        }
Ejemplo n.º 8
0
 public AniDB_Episode GetByEpisodeID(int id)
 {
     using (var session = JMMService.SessionFactory.OpenSession())
     {
         AniDB_Episode cr = session
                            .CreateCriteria(typeof(AniDB_Episode))
                            .Add(Restrictions.Eq("EpisodeID", id))
                            .UniqueResult <AniDB_Episode>();
         return(cr);
     }
 }
Ejemplo n.º 9
0
 public EpisodeDetails(AniDB_Episode episode, SVR_AniDB_Anime anime, SVR_AnimeSeries series = null)
 {
     ID           = episode.EpisodeID;
     Title        = Episode.GetEpisodeTitle(episode.EpisodeID);
     Number       = episode.EpisodeNumber;
     Type         = Episode.MapAniDBEpisodeType(episode.GetEpisodeTypeEnum());
     AirDate      = (DateTime)episode.GetAirDateAsDate();
     InCollection = series != null;
     SeriesID     = anime.AnimeID;
     SeriesTitle  = series?.GetSeriesName() ?? anime.PreferredTitle;
     SeriesPoster = Series.GetDefaultImage(anime.AnimeID, ImageSizeType.Poster) ?? Series.GetAniDBPoster(anime.AnimeID);
 }
Ejemplo n.º 10
0
 public void Save(AniDB_Episode obj)
 {
     using (var session = JMMService.SessionFactory.OpenSession())
     {
         // populate the database
         using (var transaction = session.BeginTransaction())
         {
             session.SaveOrUpdate(obj);
             transaction.Commit();
         }
     }
 }
Ejemplo n.º 11
0
        public static void CreateAnimeEpisode(this AniDB_Episode episode, ISession session, int animeSeriesID)
        {
            // check if there is an existing episode for this EpisodeID
            SVR_AnimeEpisode existingEp = RepoFactory.AnimeEpisode.GetByAniDBEpisodeID(episode.EpisodeID) ??
                                          new SVR_AnimeEpisode();

            existingEp.Populate(episode);
            existingEp.AnimeSeriesID = animeSeriesID;
            RepoFactory.AnimeEpisode.Save(existingEp);

            // We might have removed our AnimeEpisode_User records when wiping out AnimeEpisodes, recreate them if there's watched files
            var vlUsers = existingEp?.GetVideoLocals()
                          .SelectMany(a => RepoFactory.VideoLocalUser.GetByVideoLocalID(a.VideoLocalID)).ToList();

            // get the list of unique users
            var users = vlUsers.Select(a => a.JMMUserID).Distinct();

            if (vlUsers.Count > 0)
            {
                // per user. An episode is watched if any file is
                foreach (int uid in users)
                {
                    // get the last watched file
                    var vlUser = vlUsers.Where(a => a.JMMUserID == uid && a.WatchedDate != null)
                                 .MaxBy(a => a.WatchedDate).FirstOrDefault();
                    // create or update the record
                    var epUser = RepoFactory.AnimeEpisode_User.GetByUserIDAndEpisodeID(uid, existingEp.AnimeEpisodeID);
                    if (epUser == null)
                    {
                        epUser = new SVR_AnimeEpisode_User
                        {
                            JMMUserID      = uid,
                            WatchedDate    = vlUser?.WatchedDate,
                            PlayedCount    = vlUser != null ? 1 : 0,
                            WatchedCount   = vlUser != null ? 1 : 0,
                            AnimeSeriesID  = animeSeriesID,
                            AnimeEpisodeID = existingEp.AnimeEpisodeID
                        };
                        RepoFactory.AnimeEpisode_User.Save(epUser);
                    }
                }
            }
            else
            {
                // since these are created with VideoLocal_User,
                // these will probably never exist, but if they do, cover our bases
                foreach (var episodeUser in RepoFactory.AnimeEpisode_User.GetByEpisodeID(existingEp.AnimeEpisodeID))
                {
                    RepoFactory.AnimeEpisode_User.Save(episodeUser);
                }
            }
        }
Ejemplo n.º 12
0
        public static void Init()
        {
            JMMUser.Populate();
            CloudAccount.Populate();
            ImportFolder.Populate();
            AniDB_Anime.Populate();
            AniDB_Episode.Populate();
            AniDB_File.Populate();
            AniDB_Anime_Title.Populate();
            AniDB_Anime_Tag.Populate();
            AniDB_Tag.Populate();
            CustomTag.Populate();
            CrossRef_CustomTag.Populate();
            CrossRef_File_Episode.Populate();
            VideoLocalPlace.Populate();
            VideoLocal.Populate();
            VideoLocalUser.Populate();
            GroupFilter.Populate();
            AnimeEpisode.Populate();
            AnimeEpisode_User.Populate();
            AnimeSeries.Populate();
            AnimeSeries_User.Populate();
            AnimeGroup.Populate();
            AnimeGroup_User.Populate();

            // Update Contracts if necessary
            JMMUser.RegenerateDb();
            CloudAccount.RegenerateDb();
            ImportFolder.RegenerateDb();
            AniDB_Anime.RegenerateDb();
            AniDB_Episode.RegenerateDb();
            AniDB_File.RegenerateDb();
            AniDB_Anime_Title.RegenerateDb();
            AniDB_Anime_Tag.RegenerateDb();
            AniDB_Tag.RegenerateDb();
            CustomTag.RegenerateDb();
            CrossRef_CustomTag.RegenerateDb();
            CrossRef_File_Episode.RegenerateDb();
            VideoLocalPlace.RegenerateDb();
            VideoLocal.RegenerateDb();
            VideoLocalUser.RegenerateDb();
            AnimeEpisode.RegenerateDb();
            AnimeEpisode_User.RegenerateDb();
            AnimeSeries.RegenerateDb();
            AnimeSeries_User.RegenerateDb();
            AnimeGroup.RegenerateDb();
            AnimeGroup_User.RegenerateDb();

            GroupFilter.RegenerateDb();
            GroupFilter.PostProcess();
            CleanUpMemory();
        }
Ejemplo n.º 13
0
        public static void CreateAnimeEpisode(this AniDB_Episode episode, int animeSeriesID)
        {
            SVR_AnimeEpisode existingEp;

            // check if there is an existing episode for this EpisodeID
            using (var upd = Repo.Instance.AnimeEpisode.BeginAddOrUpdate(() => Repo.Instance.AnimeEpisode.GetByAniDBEpisodeID(episode.EpisodeID)))
            {
                upd.Entity.Populate_RA(episode);
                upd.Entity.AnimeSeriesID = animeSeriesID;
                existingEp = upd.Commit();
            }
            Repo.Instance.AnimeEpisode_User.Touch(() => Repo.Instance.AnimeEpisode_User.GetByEpisodeID(existingEp.AnimeEpisodeID));
        }
Ejemplo n.º 14
0
 public static void Populate(this AniDB_Episode episode, Raw_AniDB_Episode epInfo)
 {
     episode.AirDate         = epInfo.AirDate;
     episode.AnimeID         = epInfo.AnimeID;
     episode.DateTimeUpdated = DateTime.Now;
     episode.EpisodeID       = epInfo.EpisodeID;
     episode.EpisodeNumber   = epInfo.EpisodeNumber;
     episode.EpisodeType     = epInfo.EpisodeType;
     episode.LengthSeconds   = epInfo.LengthSeconds;
     episode.Rating          = epInfo.Rating.ToString(CultureInfo.InvariantCulture);
     episode.Votes           = epInfo.Votes.ToString(CultureInfo.InvariantCulture);
     episode.Description     = epInfo.Description ?? string.Empty;
 }
Ejemplo n.º 15
0
        public static void CreateAnimeEpisode(this AniDB_Episode episode, ISession session, int animeSeriesID)
        {
            // check if there is an existing episode for this EpisodeID
            SVR_AnimeEpisode existingEp = RepoFactory.AnimeEpisode.GetByAniDBEpisodeID(episode.EpisodeID);

            if (existingEp == null)
            {
                SVR_AnimeEpisode animeEp = new SVR_AnimeEpisode();
                animeEp.Populate(episode);
                animeEp.AnimeSeriesID = animeSeriesID;
                RepoFactory.AnimeEpisode.Save(animeEp);
            }
        }
Ejemplo n.º 16
0
 public static void Populate(this AniDB_Episode episode, Raw_AniDB_Episode epInfo)
 {
     episode.AirDate         = epInfo.AirDate;
     episode.AnimeID         = epInfo.AnimeID;
     episode.DateTimeUpdated = DateTime.Now;
     episode.EnglishName     = epInfo.EnglishName;
     episode.EpisodeID       = epInfo.EpisodeID;
     episode.EpisodeNumber   = epInfo.EpisodeNumber;
     episode.EpisodeType     = epInfo.EpisodeType;
     episode.LengthSeconds   = epInfo.LengthSeconds;
     episode.Rating          = epInfo.Rating.ToString();
     episode.RomajiName      = epInfo.RomajiName;
     episode.Votes           = epInfo.Votes.ToString();
 }
Ejemplo n.º 17
0
        private static TvDB_Episode GetTvDBEpisodeFromAniDB(ISession session, AniDB_Episode aep, CrossRef_AniDB_TvDBV2 xref_tvdb2)
        {
            int epnumber = (aep.EpisodeNumber + xref_tvdb2.TvDBStartEpisodeNumber - 1) -
                           (xref_tvdb2.AniDBStartEpisodeNumber - 1);
            TvDB_Episode        tvep     = null;
            int                 season   = xref_tvdb2.TvDBSeasonNumber;
            List <TvDB_Episode> tvdb_eps = RepoFactory.TvDB_Episode.GetBySeriesIDAndSeasonNumber(xref_tvdb2.TvDBID, season);

            tvep = tvdb_eps.Find(a => a.EpisodeNumber == epnumber);
            if (tvep != null)
            {
                return(tvep);
            }

            int lastSeason           = RepoFactory.TvDB_Episode.getLastSeasonForSeries(xref_tvdb2.TvDBID);
            int previousSeasonsCount = 0;

            // we checked once, so increment the season
            season++;
            previousSeasonsCount += tvdb_eps.Count;
            do
            {
                if (season == 0)
                {
                    break;                  // Specials will often be wrong
                }
                if (season > lastSeason)
                {
                    break;
                }
                if (epnumber - previousSeasonsCount <= 0)
                {
                    break;
                }
                // This should be 1 or 0, hopefully 1
                tvdb_eps = RepoFactory.TvDB_Episode.GetBySeriesIDAndSeasonNumber(xref_tvdb2.TvDBID, season);
                tvep     = tvdb_eps.Find(a => a.EpisodeNumber == epnumber - previousSeasonsCount);

                AddCrossRef_AniDB_TvDBV2(session, aep.AnimeID, previousSeasonsCount + 1, xref_tvdb2.TvDBID, season, xref_tvdb2.GetTvDBSeries()?.SeriesName ?? "");

                if (tvep != null)
                {
                    break;
                }
                previousSeasonsCount += tvdb_eps.Count;
                season++;
            } while (true);
            return(tvep);
        }
Ejemplo n.º 18
0
 public void Delete(int id)
 {
     using (var session = JMMService.SessionFactory.OpenSession())
     {
         // populate the database
         using (var transaction = session.BeginTransaction())
         {
             AniDB_Episode cr = GetByID(id);
             if (cr != null)
             {
                 session.Delete(cr);
                 transaction.Commit();
             }
         }
     }
 }
Ejemplo n.º 19
0
        public void UpdateContract(SVR_AnimeEpisode_User aeu)
        {
            CL_AnimeEpisode_User caep = aeu.Contract ?? new CL_AnimeEpisode_User();
            SVR_AnimeEpisode     ep   = Repo.Instance.AnimeEpisode.GetByID(aeu.AnimeEpisodeID);

            if (ep == null)
            {
                return;
            }
            AniDB_Episode aniEp = ep.AniDB_Episode;

            caep.AniDB_EpisodeID = ep.AniDB_EpisodeID;
            caep.AnimeEpisodeID  = ep.AnimeEpisodeID;
            caep.AnimeSeriesID   = ep.AnimeSeriesID;
            caep.DateTimeUpdated = ep.DateTimeUpdated;
            caep.PlayedCount     = aeu.PlayedCount;
            caep.StoppedCount    = aeu.StoppedCount;
            caep.WatchedCount    = aeu.WatchedCount;
            caep.WatchedDate     = aeu.WatchedDate;
            var englishTitle = Repo.Instance.AniDB_Episode_Title.GetByEpisodeIDAndLanguage(ep.AniDB_EpisodeID, "EN")
                               .FirstOrDefault()?.Title;
            var romajiTitle = Repo.Instance.AniDB_Episode_Title.GetByEpisodeIDAndLanguage(ep.AniDB_EpisodeID, "X-JAT")
                              .FirstOrDefault()?.Title;

            caep.AniDB_EnglishName  = englishTitle;
            caep.AniDB_RomajiName   = romajiTitle;
            caep.EpisodeNameEnglish = englishTitle;
            caep.EpisodeNameRomaji  = romajiTitle;
            if (aniEp != null)
            {
                caep.AniDB_AirDate       = aniEp.GetAirDateAsDate();
                caep.AniDB_LengthSeconds = aniEp.LengthSeconds;
                caep.AniDB_Rating        = aniEp.Rating;
                caep.AniDB_Votes         = aniEp.Votes;

                caep.EpisodeNumber = aniEp.EpisodeNumber;
                caep.Description   = aniEp.Description;
                caep.EpisodeType   = aniEp.EpisodeType;
            }

            /*
             * //TODO if this is needed, calculating it in here will not affect performance
             * caep.ReleaseGroups = new List<CL_AniDB_GroupStatus>();
             */
            aeu.Contract = caep;
        }
Ejemplo n.º 20
0
        public static CL_AniDB_Episode ToClient(this AniDB_Episode ep)
        {
            var titles = Repo.Instance.AniDB_Episode_Title.GetByEpisodeID(ep.EpisodeID);

            return(new CL_AniDB_Episode
            {
                EpisodeID = ep.EpisodeID,
                AnimeID = ep.AnimeID,
                LengthSeconds = ep.LengthSeconds,
                Rating = ep.Rating,
                Votes = ep.Votes,
                EpisodeNumber = ep.EpisodeNumber,
                EpisodeType = ep.EpisodeType,
                Description = ep.Description,
                AirDate = ep.AirDate,
                DateTimeUpdated = ep.DateTimeUpdated,
                Titles = titles.ToDictionary(a => a.Language, a => a.Title)
            });
        }
Ejemplo n.º 21
0
        public static void CreateAnimeEpisode(this AniDB_Episode episode, int animeSeriesID)
        {
            SVR_AnimeEpisode existingEp;

            // check if there is an existing episode for this EpisodeID
            using (var upd = Repo.Instance.AnimeEpisode.BeginAddOrUpdate(() => Repo.Instance.AnimeEpisode.GetByAniDBEpisodeID(episode.EpisodeID)))
            {
                upd.Entity.Populate_RA(episode);
                upd.Entity.AnimeSeriesID = animeSeriesID;
                existingEp = upd.Commit();
            }

            // We might have removed our AnimeEpisode_User records when wiping out AnimeEpisodes, recreate them if there's watched files
            foreach (var videoLocal in existingEp.GetVideoLocals())
            {
                var videoLocalUsers = Repo.Instance.VideoLocal_User.GetByVideoLocalID(videoLocal.VideoLocalID);
                if (videoLocalUsers.Count > 0)
                {
                    foreach (var videoLocalUser in videoLocalUsers)
                    {
                        using (var upd = Repo.Instance.AnimeEpisode_User.BeginAddOrUpdate(() =>
                                                                                          Repo.Instance.AnimeEpisode_User.GetByUserIDAndEpisodeID(
                                                                                              videoLocalUser.JMMUserID,
                                                                                              existingEp.AnimeEpisodeID)))
                        {
                            upd.Entity.JMMUserID      = videoLocalUser.JMMUserID;
                            upd.Entity.WatchedDate    = videoLocalUser.WatchedDate;
                            upd.Entity.PlayedCount    = videoLocalUser.WatchedDate.HasValue ? 1 : 0;
                            upd.Entity.WatchedCount   = videoLocalUser.WatchedDate.HasValue ? 1 : 0;
                            upd.Entity.AnimeSeriesID  = animeSeriesID;
                            upd.Entity.AnimeEpisodeID = existingEp.AnimeEpisodeID;
                            upd.Commit();
                        }
                    }
                }
                else
                {
                    // these will probably never exist, but if they do, cover our bases
                    Repo.Instance.AnimeEpisode_User.Touch(() => Repo.Instance.AnimeEpisode_User.GetByEpisodeID(existingEp.AnimeEpisodeID));
                }
            }
        }
        public void UpdateContract(ISession session, AnimeEpisode_User aeu)
        {
            AnimeEpisodeRepository aerepo = new AnimeEpisodeRepository();
            Contract_AnimeEpisode  caep   = aeu.Contract ?? new Contract_AnimeEpisode();
            AnimeEpisode           ep     = aerepo.GetByID(aeu.AnimeEpisodeID);

            if (ep == null)
            {
                return;
            }
            AniDB_Episode aniEp = ep.AniDB_Episode;

            caep.AniDB_EpisodeID = ep.AniDB_EpisodeID;
            caep.AnimeEpisodeID  = ep.AnimeEpisodeID;
            caep.AnimeSeriesID   = ep.AnimeSeriesID;
            caep.DateTimeUpdated = ep.DateTimeUpdated;
            caep.IsWatched       = aeu.WatchedCount > 0 ? 1 : 0;
            caep.PlayedCount     = aeu.PlayedCount;
            caep.StoppedCount    = aeu.StoppedCount;
            caep.WatchedCount    = aeu.WatchedCount;
            caep.WatchedDate     = aeu.WatchedDate;
            if (aniEp != null)
            {
                caep.AniDB_AirDate       = aniEp.AirDateAsDate;
                caep.AniDB_EnglishName   = aniEp.EnglishName;
                caep.AniDB_LengthSeconds = aniEp.LengthSeconds;
                caep.AniDB_Rating        = aniEp.Rating;
                caep.AniDB_RomajiName    = aniEp.RomajiName;
                caep.AniDB_Votes         = aniEp.Votes;

                caep.EpisodeNumber      = aniEp.EpisodeNumber;
                caep.EpisodeNameRomaji  = aniEp.RomajiName;
                caep.EpisodeNameEnglish = aniEp.EnglishName;
                caep.EpisodeType        = aniEp.EpisodeType;
            }


            //TODO if this is needed, calculating it in here will not affect performance
            caep.ReleaseGroups = new List <Contract_AniDBReleaseGroup>();

            aeu.Contract = caep;
        }
Ejemplo n.º 23
0
        public void UpdateContract(SVR_AnimeEpisode_User aeu)
        {
            Shoko.Models.Client.CL_AnimeEpisode_User caep = aeu.Contract ?? new CL_AnimeEpisode_User();
            SVR_AnimeEpisode ep = RepoFactory.AnimeEpisode.GetByID(aeu.AnimeEpisodeID);

            if (ep == null)
            {
                return;
            }
            AniDB_Episode aniEp = ep.AniDB_Episode;

            caep.AniDB_EpisodeID = ep.AniDB_EpisodeID;
            caep.AnimeEpisodeID  = ep.AnimeEpisodeID;
            caep.AnimeSeriesID   = ep.AnimeSeriesID;
            caep.DateTimeUpdated = ep.DateTimeUpdated;
            caep.PlayedCount     = aeu.PlayedCount;
            caep.StoppedCount    = aeu.StoppedCount;
            caep.WatchedCount    = aeu.WatchedCount;
            caep.WatchedDate     = aeu.WatchedDate;
            if (aniEp != null)
            {
                caep.AniDB_AirDate       = aniEp.GetAirDateAsDate();
                caep.AniDB_EnglishName   = aniEp.EnglishName;
                caep.AniDB_LengthSeconds = aniEp.LengthSeconds;
                caep.AniDB_Rating        = aniEp.Rating;
                caep.AniDB_RomajiName    = aniEp.RomajiName;
                caep.AniDB_Votes         = aniEp.Votes;

                caep.EpisodeNumber      = aniEp.EpisodeNumber;
                caep.EpisodeNameRomaji  = aniEp.RomajiName;
                caep.EpisodeNameEnglish = aniEp.EnglishName;
                caep.EpisodeType        = aniEp.EpisodeType;
            }

            /*
             * //TODO if this is needed, calculating it in here will not affect performance
             * caep.ReleaseGroups = new List<CL_AniDB_GroupStatus>();
             */
            aeu.Contract = caep;
        }
Ejemplo n.º 24
0
        public static void LinkAniDBTvDBEpisode(int aniDBID, int tvDBID)
        {
            AniDB_Episode ep   = Repo.Instance.AniDB_Episode.GetByEpisodeID(aniDBID);
            TvDB_Episode  tvep = Repo.Instance.TvDB_Episode.GetByID(tvDBID);

            using (var upd = Repo.Instance.CrossRef_AniDB_Provider.BeginAddOrUpdate(() => Repo.Instance.CrossRef_AniDB_Provider.GetByAnimeIdAndProvider(CrossRefType.TvDB, ep.AnimeID, tvep.SeriesID.ToString())))
            {
                upd.Entity.EpisodesListOverride.AddOrUpdate(aniDBID, tvDBID.ToString(), tvep.SeasonNumber, ep.EpisodeNumber, ep.GetEpisodeTypeEnum(), MatchRating.UserVerified);
                if (upd.Entity.EpisodesListOverride.NeedPersitance)
                {
                    upd.Commit();
                }
            }

            using (var upd = Repo.Instance.AnimeEpisode.BeginAddOrUpdate(() => Repo.Instance.AnimeEpisode.GetByAniDBEpisodeID(aniDBID)))
            {
                SVR_AniDB_Anime.UpdateStatsByAnimeID(ep.AnimeID);
                upd.Commit();
            }

            logger.Trace($"Changed tvdb episode association: {aniDBID}");
        }
Ejemplo n.º 25
0
        public static AniDB GetAniDBInfo(AniDB_Episode ep)
        {
            decimal rating = 0;
            int     votes  = 0;

            try
            {
                rating = decimal.Parse(ep.Rating);
                votes  = int.Parse(ep.Votes);
            }
            catch {}

            var titles = RepoFactory.AniDB_Episode_Title.GetByEpisodeID(ep.EpisodeID);

            return(new AniDB
            {
                ID = ep.EpisodeID,
                Type = (EpisodeType)ep.EpisodeType,
                EpisodeNumber = ep.EpisodeNumber,
                AirDate = ep.GetAirDateAsDate(),
                Description = ep.Description,
                Rating = new Rating
                {
                    Source = "AniDB",
                    Value = rating,
                    MaxValue = 10,
                    Votes = votes
                },
                Titles = titles.Select(a => new Title
                {
                    Source = "AniDB",
                    Name = a.Title,
                    Language = a.Language
                }).ToList()
            });
        }
        private void ProcessFile_AniDB(SVR_VideoLocal vidLocal)
        {
            logger.Trace($"Checking for AniDB_File record for: {vidLocal.Hash} --- {vidLocal.FileName}");
            // check if we already have this AniDB_File info in the database

            lock (vidLocal)
            {
                SVR_AniDB_File aniFile = null;

                if (!ForceAniDB)
                {
                    aniFile = Repo.Instance.AniDB_File.GetByHashAndFileSize(vidLocal.Hash, vlocal.FileSize);

                    if (aniFile == null)
                    {
                        logger.Trace("AniDB_File record not found");
                    }
                }
                // If cross refs were wiped, but the AniDB_File was not, we unfortunately need to requery the info
                List <CrossRef_File_Episode> crossRefs = Repo.Instance.CrossRef_File_Episode.GetByHash(vidLocal.Hash);
                if (crossRefs == null || crossRefs.Count == 0)
                {
                    aniFile = null;
                }

                int animeID = 0;

                if (aniFile == null)
                {
                    // get info from AniDB
                    logger.Debug("Getting AniDB_File record from AniDB....");

                    // check if we already have a record

                    using (var upd = Repo.Instance.AniDB_File.BeginAddOrUpdate(() => Repo.Instance.AniDB_File.GetByHashAndFileSize(vidLocal.Hash, vlocal.FileSize)))
                    {
                        bool skip = false;
                        if (!upd.IsUpdate)
                        {
                            Raw_AniDB_File fileInfo = ShokoService.AnidbProcessor.GetFileInfo(vidLocal);
                            if (fileInfo != null)
                            {
                                upd.Entity.Populate_RA(fileInfo);
                            }
                            else
                            {
                                skip = true;
                            }
                        }

                        if (!skip)
                        {
                            //overwrite with local file name
                            string localFileName = vidLocal.GetBestVideoLocalPlace()?.FullServerPath;
                            localFileName = !string.IsNullOrEmpty(localFileName)
                                ? Path.GetFileName(localFileName)
                                : vidLocal.FileName;
                            upd.Entity.FileName = localFileName;

                            aniFile = upd.Commit(false);
                            aniFile.CreateLanguages();
                            aniFile.CreateCrossEpisodes(localFileName);

                            animeID = aniFile.AnimeID;
                        }

                        upd.Commit();
                    }
                }

                bool missingEpisodes = false;

                // if we still haven't got the AniDB_File Info we try the web cache or local records
                if (aniFile == null)
                {
                    // check if we have any records from previous imports
                    crossRefs = Repo.Instance.CrossRef_File_Episode.GetByHash(vidLocal.Hash);
                    if (crossRefs == null || crossRefs.Count == 0)
                    {
                        // lets see if we can find the episode/anime info from the web cache
                        if (ServerSettings.Instance.WebCache.XRefFileEpisode_Get)
                        {
                            List <Azure_CrossRef_File_Episode> xrefs =
                                AzureWebAPI.Get_CrossRefFileEpisode(vidLocal);

                            crossRefs = new List <CrossRef_File_Episode>();
                            if (xrefs == null || xrefs.Count == 0)
                            {
                                logger.Debug(
                                    $"Cannot find AniDB_File record or get cross ref from web cache record so exiting: {vidLocal.ED2KHash}");
                                return;
                            }
                            string fileName = vidLocal.GetBestVideoLocalPlace()?.FullServerPath;
                            fileName = !string.IsNullOrEmpty(fileName) ? Path.GetFileName(fileName) : vidLocal.FileName;
                            foreach (Azure_CrossRef_File_Episode xref in xrefs)
                            {
                                CrossRef_File_Episode xrefEnt = new CrossRef_File_Episode
                                {
                                    Hash           = vidLocal.ED2KHash,
                                    FileName       = fileName,
                                    FileSize       = vidLocal.FileSize,
                                    CrossRefSource = (int)CrossRefSource.WebCache,
                                    AnimeID        = xref.AnimeID,
                                    EpisodeID      = xref.EpisodeID,
                                    Percentage     = xref.Percentage,
                                    EpisodeOrder   = xref.EpisodeOrder
                                };
                                bool duplicate = false;

                                foreach (CrossRef_File_Episode xrefcheck in crossRefs)
                                {
                                    if (xrefcheck.AnimeID == xrefEnt.AnimeID &&
                                        xrefcheck.EpisodeID == xrefEnt.EpisodeID &&
                                        xrefcheck.Hash == xrefEnt.Hash)
                                    {
                                        duplicate = true;
                                    }
                                }

                                if (!duplicate)
                                {
                                    crossRefs.Add(xrefEnt);
                                    // in this case we need to save the cross refs manually as AniDB did not provide them
                                    Repo.Instance.CrossRef_File_Episode.BeginAdd(xrefEnt).Commit();
                                }
                            }
                        }
                        else
                        {
                            logger.Debug($"Cannot get AniDB_File record so exiting: {vidLocal.ED2KHash}");
                            return;
                        }
                    }

                    // we assume that all episodes belong to the same anime
                    foreach (CrossRef_File_Episode xref in crossRefs)
                    {
                        animeID = xref.AnimeID;

                        AniDB_Episode ep = Repo.Instance.AniDB_Episode.GetByEpisodeID(xref.EpisodeID);
                        if (ep == null)
                        {
                            missingEpisodes = true;
                        }
                    }
                }
                else
                {
                    // check if we have the episode info
                    // if we don't, we will need to re-download the anime info (which also has episode info)

                    if (aniFile.EpisodeCrossRefs.Count == 0)
                    {
                        animeID = aniFile.AnimeID;

                        // if we have the anidb file, but no cross refs it means something has been broken
                        logger.Debug($"Could not find any cross ref records for: {vidLocal.ED2KHash}");
                        missingEpisodes = true;
                    }
                    else
                    {
                        foreach (CrossRef_File_Episode xref in aniFile.EpisodeCrossRefs)
                        {
                            AniDB_Episode ep = Repo.Instance.AniDB_Episode.GetByEpisodeID(xref.EpisodeID);
                            if (ep == null)
                            {
                                missingEpisodes = true;
                            }

                            animeID = xref.AnimeID;
                        }
                    }
                }

                // get from DB
                SVR_AniDB_Anime anime  = Repo.Instance.AniDB_Anime.GetByAnimeID(animeID);
                var             update = Repo.Instance.AniDB_AnimeUpdate.GetByAnimeID(animeID);
                bool            animeRecentlyUpdated = false;

                if (anime != null && update != null)
                {
                    TimeSpan ts = DateTime.Now - update.UpdatedAt;
                    if (ts.TotalHours < 4)
                    {
                        animeRecentlyUpdated = true;
                    }
                }
                else
                {
                    missingEpisodes = true;
                }

                // even if we are missing episode info, don't get data  more than once every 4 hours
                // this is to prevent banning
                if (missingEpisodes && !animeRecentlyUpdated)
                {
                    logger.Debug("Getting Anime record from AniDB....");
                    anime = ShokoService.AnidbProcessor.GetAnimeInfoHTTP(animeID, true,
                                                                         ServerSettings.Instance.AutoGroupSeries || ServerSettings.Instance.AniDb.DownloadRelatedAnime);
                }

                // create the group/series/episode records if needed
                if (anime != null)
                {
                    logger.Debug("Creating groups, series and episodes....");
                    // check if there is an AnimeSeries Record associated with this AnimeID
                    SVR_AnimeSeries ser;
                    using (var upd = Repo.Instance.AnimeSeries.BeginAddOrUpdate(
                               () => Repo.Instance.AnimeSeries.GetByAnimeID(animeID),
                               () => anime.CreateAnimeSeriesAndGroup()
                               ))
                    {
                        upd.Entity.CreateAnimeEpisodes();

                        // check if we have any group status data for this associated anime
                        // if not we will download it now
                        if (Repo.Instance.AniDB_GroupStatus.GetByAnimeID(anime.AnimeID).Count == 0)
                        {
                            CommandRequest_GetReleaseGroupStatus cmdStatus =
                                new CommandRequest_GetReleaseGroupStatus(anime.AnimeID, false);
                            cmdStatus.Save();
                        }

                        // update stats
                        upd.Entity.EpisodeAddedDate = DateTime.Now;
                        ser = upd.Commit();
                    }

                    Repo.Instance.AnimeGroup.BatchAction(ser.AllGroupsAbove, ser.AllGroupsAbove.Count, (grp, _) => grp.EpisodeAddedDate = DateTime.Now, (true, false, false));

                    // We do this inside, as the info will not be available as needed otherwise
                    List <SVR_VideoLocal> videoLocals =
                        aniFile?.EpisodeIDs?.SelectMany(a => Repo.Instance.VideoLocal.GetByAniDBEpisodeID(a))
                        .Where(b => b != null)
                        .ToList();
                    if (videoLocals != null)
                    {
                        // Copy over watched states
                        foreach (var user in Repo.Instance.JMMUser.GetAll())
                        {
                            var watchedVideo = videoLocals.FirstOrDefault(a =>
                                                                          a?.GetUserRecord(user.JMMUserID)?.WatchedDate != null);
                            // No files that are watched
                            if (watchedVideo == null)
                            {
                                continue;
                            }

                            var watchedRecord = watchedVideo.GetUserRecord(user.JMMUserID);

                            using (var upd = Repo.Instance.VideoLocal_User.BeginAddOrUpdate(
                                       () => vidLocal.GetUserRecord(user.JMMUserID),
                                       () => new VideoLocal_User {
                                JMMUserID = user.JMMUserID, VideoLocalID = vidLocal.VideoLocalID
                            }
                                       ))
                            {
                                upd.Entity.WatchedDate    = watchedRecord.WatchedDate;
                                upd.Entity.ResumePosition = watchedRecord.ResumePosition;
                                upd.Commit();
                            }
                        }

                        if (ServerSettings.Instance.FileQualityFilterEnabled)
                        {
                            videoLocals.Sort(FileQualityFilter.CompareTo);
                            List <SVR_VideoLocal> keep = videoLocals
                                                         .Take(FileQualityFilter.Settings.MaxNumberOfFilesToKeep)
                                                         .ToList();
                            foreach (SVR_VideoLocal vl2 in keep)
                            {
                                videoLocals.Remove(vl2);
                            }
                            if (!FileQualityFilter.Settings.AllowDeletionOfImportedFiles &&
                                videoLocals.Contains(vidLocal))
                            {
                                videoLocals.Remove(vidLocal);
                            }
                            videoLocals = videoLocals.Where(a => !FileQualityFilter.CheckFileKeep(a)).ToList();

                            videoLocals.ForEach(a => a.Places.ForEach(b => b.RemoveAndDeleteFile()));
                        }
                    }

                    // update stats for groups and series
                    // update all the groups above this series in the heirarchy
                    SVR_AniDB_Anime.UpdateStatsByAnimeID(animeID);
                }
                else
                {
                    logger.Warn($"Unable to create AniDB_Anime for file: {vidLocal.FileName}");
                }
                vidLocal.Places.ForEach(a => { a.RenameAndMoveAsRequired(); });

                // Add this file to the users list
                if (ServerSettings.Instance.AniDb.MyList_AddFiles)
                {
                    CommandRequest_AddFileToMyList cmd = new CommandRequest_AddFileToMyList(vidLocal.ED2KHash);
                    cmd.Save();
                }
            }
        }
Ejemplo n.º 27
0
        public bool Init(AnimeEpisode aniepisode)
        {
            try
            {
                if (string.IsNullOrEmpty(ServerSettings.Trakt_Username) || string.IsNullOrEmpty(ServerSettings.Trakt_Password))
                {
                    return(false);
                }

                username = ServerSettings.Trakt_Username;
                password = Utils.CalculateSHA1(ServerSettings.Trakt_Password, Encoding.Default);

                imdb_id = "";
                AnimeSeries ser = aniepisode.GetAnimeSeries();
                if (ser == null)
                {
                    return(false);
                }

                CrossRef_AniDB_TraktRepository repCrossRef = new CrossRef_AniDB_TraktRepository();
                CrossRef_AniDB_Trakt           xref        = repCrossRef.GetByAnimeID(ser.AniDB_ID);
                if (xref == null)
                {
                    return(false);
                }

                Trakt_ShowRepository repShows = new Trakt_ShowRepository();
                Trakt_Show           show     = repShows.GetByTraktID(xref.TraktID);
                if (show == null)
                {
                    return(false);
                }
                if (!show.TvDB_ID.HasValue)
                {
                    return(false);
                }

                tvdb_id = show.TvDB_ID.Value.ToString();
                title   = show.Title;
                year    = show.Year;

                int retEpNum = 0, retSeason = 0;
                GetTraktEpisodeNumber(aniepisode, show, xref.TraktSeasonNumber, ref retEpNum, ref retSeason);
                if (retEpNum < 0)
                {
                    return(false);
                }

                episode = retEpNum.ToString();
                season  = retSeason.ToString();

                AniDB_Episode aniep = aniepisode.AniDB_Episode;
                if (aniep != null)
                {
                    TimeSpan t         = TimeSpan.FromSeconds(aniep.LengthSeconds + 14);
                    int      toMinutes = int.Parse(Math.Round(t.TotalMinutes).ToString());
                    duration = toMinutes.ToString();
                }
                else
                {
                    duration = "25";
                }

                progress = "100";

                plugin_version       = "0.4";
                media_center_version = "1.2.0.1";
                media_center_date    = "Dec 17 2010";
            }
            catch (Exception ex)
            {
                logger.ErrorException(ex.ToString(), ex);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 28
0
        public static Video GenerateVideoFromAnimeEpisode(SVR_AnimeEpisode ep, int userID)
        {
            Video l = new Video();
            List <SVR_VideoLocal> vids = ep.GetVideoLocals();

            l.Type      = "episode";
            l.Summary   = "Episode Overview Not Available"; //TODO Intenationalization
            l.Id        = ep.AnimeEpisodeID;
            l.AnimeType = AnimeTypes.AnimeEpisode.ToString();
            if (vids.Count > 0)
            {
                //List<string> hashes = vids.Select(a => a.Hash).Distinct().ToList();
                l.Title                 = Path.GetFileNameWithoutExtension(vids[0].FileName);
                l.AddedAt               = vids[0].DateTimeCreated.ToUnixTime();
                l.UpdatedAt             = vids[0].DateTimeUpdated.ToUnixTime();
                l.OriginallyAvailableAt = vids[0].DateTimeCreated.ToPlexDate();
                l.Year   = vids[0].DateTimeCreated.Year;
                l.Medias = new List <Media>();
                foreach (SVR_VideoLocal v in vids)
                {
                    if (v?.Media == null)
                    {
                        continue;
                    }
                    var legacy = new Media(v.VideoLocalID, v.Media);
                    var place  = v.GetBestVideoLocalPlace();
                    legacy.Parts.ForEach(p =>
                    {
                        if (string.IsNullOrEmpty(p.LocalKey))
                        {
                            p.LocalKey = place.FullServerPath;
                        }
                        string name = UrlSafe.Replace(Path.GetFileName(place.FilePath), " ").CompactWhitespaces()
                                      .Trim();
                        name = UrlSafe2.Replace(name, string.Empty)
                               .Trim()
                               .CompactCharacters('.')
                               .Replace(" ", "_")
                               .CompactCharacters('_')
                               .Replace("_.", ".");
                        while (name.StartsWith("_"))
                        {
                            name = name.Substring(1);
                        }
                        while (name.StartsWith("."))
                        {
                            name = name.Substring(1);
                        }
                        p.Key = ((IProvider)null).ReplaceSchemeHost(
                            ((IProvider)null).ConstructVideoLocalStream(userID, v.VideoLocalID, name, false));
                        if (p.Streams == null)
                        {
                            return;
                        }
                        foreach (Stream s in p.Streams.Where(a => a.File != null && a.StreamType == 3).ToList())
                        {
                            s.Key =
                                ((IProvider)null).ReplaceSchemeHost(
                                    ((IProvider)null).ConstructFileStream(userID, s.File, false));
                        }
                    });
                    l.Medias.Add(legacy);
                }

                string title = ep.Title;
                if (!String.IsNullOrEmpty(title))
                {
                    l.Title = title;
                }

                string romaji = RepoFactory.AniDB_Episode_Title.GetByEpisodeIDAndLanguage(ep.AniDB_EpisodeID, "X-JAT")
                                .FirstOrDefault()?.Title;
                if (!String.IsNullOrEmpty(romaji))
                {
                    l.OriginalTitle = romaji;
                }

                AniDB_Episode aep = ep?.AniDB_Episode;
                if (aep != null)
                {
                    l.EpisodeNumber = aep.EpisodeNumber;
                    l.Index         = aep.EpisodeNumber;
                    l.EpisodeType   = aep.EpisodeType;
                    l.Rating        = (int)Single.Parse(aep.Rating, CultureInfo.InvariantCulture);
                    AniDB_Vote vote =
                        RepoFactory.AniDB_Vote.GetByEntityAndType(ep.AnimeEpisodeID, AniDBVoteType.Episode);
                    if (vote != null)
                    {
                        l.UserRating = (int)(vote.VoteValue / 100D);
                    }

                    if (aep.GetAirDateAsDate().HasValue)
                    {
                        l.Year = aep.GetAirDateAsDate()?.Year ?? 0;
                        l.OriginallyAvailableAt = aep.GetAirDateAsDate()?.ToPlexDate();
                    }

                    #region TvDB

                    TvDB_Episode tvep = ep.TvDBEpisode;
                    if (tvep != null)
                    {
                        l.Thumb   = tvep.GenPoster(null);
                        l.Summary = tvep.Overview;
                        l.Season  = $"{tvep.SeasonNumber}x{tvep.EpisodeNumber:0#}";
                    }
                    #endregion
                }
                if (l.Thumb == null || l.Summary == null)
                {
                    l.Thumb   = ((IProvider)null).ConstructSupportImageLink("plex_404.png");
                    l.Summary = "Episode Overview not Available";
                }
            }
            l.Id = ep.AnimeEpisodeID;
            return(l);
        }
Ejemplo n.º 29
0
 public static void Populate(this SVR_AnimeEpisode animeep, AniDB_Episode anidbEp)
 {
     animeep.AniDB_EpisodeID = anidbEp.EpisodeID;
     animeep.DateTimeUpdated = DateTime.Now;
     animeep.DateTimeCreated = DateTime.Now;
 }
Ejemplo n.º 30
0
 public static string GetEnglishTitle(this AniDB_Episode ep)
 {
     return(Repo.Instance.AniDB_Episode_Title.GetByEpisodeIDAndLanguage(ep.EpisodeID, "EN").FirstOrDefault()
            ?.Title);
 }