Пример #1
0
        public static List <Tag> GetTags(HttpContext ctx, SVR_AniDB_Anime anime, TagFilter.Filter filter, bool excludeDescriptions = false)
        {
            // TODO This is probably slow. Make it faster.
            var tags = new List <Tag>();

            var allTags      = anime.GetAniDBTags().DistinctBy(a => a.TagName).ToDictionary(a => a.TagName, a => a);
            var filteredTags = TagFilter.ProcessTags(filter, allTags.Keys.ToList());

            foreach (string filteredTag in filteredTags)
            {
                AniDB_Tag tag = allTags.ContainsKey(filteredTag)
                    ? allTags[filteredTag]
                    : RepoFactory.AniDB_Tag.GetByName(filteredTag).FirstOrDefault();
                if (tag == null)
                {
                    tags.Add(new Tag {
                        Name = filteredTag
                    });
                    continue;
                }
                var toAPI = new Tag
                {
                    Name = tag.TagName
                };
                if (!excludeDescriptions)
                {
                    toAPI.Description = tag.TagDescription;
                }
                tags.Add(toAPI);
            }

            return(tags);
        }
Пример #2
0
        private void PopulateArtFromAniDBAnime(HttpContext ctx, SVR_AniDB_Anime anime)
        {
            Random rand = (Random)ctx.Items["Random"];

            // TODO Makes this more safe
            preferred_poster = new Image(ctx, anidb_id, ImageEntityType.AniDB_Cover);
            var defaultPoster = Repo.Instance.AniDB_Anime_DefaultImage.GetByAnimeIDAndImagezSizeType(anime.AnimeID,
                                                                                                     (int)ImageSizeType.Poster);

            if (defaultPoster != null)
            {
                preferred_poster = new Image(ctx, defaultPoster.ImageParentID,
                                             (ImageEntityType)defaultPoster.ImageParentType);
            }

            var tvdbIDs = Repo.Instance.CrossRef_AniDB_Provider.GetByAnimeIDAndType(anime.AnimeID, CrossRefType.TvDB).ToList();
            var fanarts = tvdbIDs.SelectMany(a => Repo.Instance.TvDB_ImageFanart.GetBySeriesID(int.Parse(a.CrossRefID))).ToList();
            var banners = tvdbIDs.SelectMany(a => Repo.Instance.TvDB_ImageWideBanner.GetBySeriesID(int.Parse(a.CrossRefID))).ToList();

            var moviedb = Repo.Instance.CrossRef_AniDB_Provider.GetByAnimeIDAndType(anime.AnimeID, CrossRefType.MovieDB).FirstOrDefault();
            List <MovieDB_Fanart> moviedbFanarts = moviedb == null
                ? new List <MovieDB_Fanart>()
                : Repo.Instance.MovieDB_Fanart.GetByMovieID(int.Parse(moviedb.CrossRefID));

            if (ctx.Items.ContainsKey("images"))
            {
                var posters = anime.AllPosters;
                images.AddRange(posters.Select(a =>
                                               new Image(ctx, a.AniDB_Anime_DefaultImageID, (ImageEntityType)a.ImageType)));

                images.AddRange(fanarts.Select(a => new Image(ctx, a.TvDB_ImageFanartID, ImageEntityType.TvDB_FanArt)));

                images.AddRange(banners.Select(a =>
                                               new Image(ctx, a.TvDB_ImageWideBannerID, ImageEntityType.TvDB_Banner)));

                images.AddRange(moviedbFanarts.Select(a =>
                                                      new Image(ctx, a.MovieDB_FanartID, ImageEntityType.MovieDB_FanArt)));
            }
            else
            {
                object fanart_object = tvdbIDs.SelectMany(a => Repo.Instance.TvDB_ImageFanart.GetBySeriesID(int.Parse(a.CrossRefID)))
                                       .Cast <object>().Concat(moviedbFanarts).GetRandomElement(rand);

                if (fanart_object is TvDB_ImageFanart tvdb_fanart)
                {
                    images.Add(new Image(ctx, tvdb_fanart.TvDB_ImageFanartID, ImageEntityType.TvDB_FanArt));
                }
                else if (fanart_object is MovieDB_Fanart moviedb_fanart)
                {
                    images.Add(new Image(ctx, moviedb_fanart.MovieDB_FanartID, ImageEntityType.MovieDB_FanArt));
                }

                var banner = tvdbIDs.SelectMany(a => Repo.Instance.TvDB_ImageWideBanner.GetBySeriesID(int.Parse(a.CrossRefID)))
                             .GetRandomElement(rand);
                if (banner != null)
                {
                    images.Add(new Image(ctx, banner.TvDB_ImageWideBannerID, ImageEntityType.TvDB_Banner));
                }
            }
        }
Пример #3
0
        public static CL_DuplicateFile ToClient(this DuplicateFile duplicatefile)
        {
            CL_DuplicateFile cl = new CL_DuplicateFile
            {
                DuplicateFileID     = duplicatefile.DuplicateFileID,
                FilePathFile1       = duplicatefile.FilePathFile1,
                FilePathFile2       = duplicatefile.FilePathFile2,
                Hash                = duplicatefile.Hash,
                ImportFolderIDFile1 = duplicatefile.ImportFolderIDFile1,
                ImportFolderIDFile2 = duplicatefile.ImportFolderIDFile2,
                ImportFolder1       = RepoFactory.ImportFolder.GetByID(duplicatefile.ImportFolderIDFile1),
                ImportFolder2       = RepoFactory.ImportFolder.GetByID(duplicatefile.ImportFolderIDFile2),
                DateTimeUpdated     = duplicatefile.DateTimeUpdated
            };

            if (duplicatefile.GetAniDBFile() != null)
            {
                List <AniDB_Episode> eps = duplicatefile.GetAniDBFile().Episodes;
                if (eps.Count > 0)
                {
                    cl.EpisodeNumber = eps[0].EpisodeNumber;
                    cl.EpisodeType   = eps[0].EpisodeType;
                    cl.EpisodeName   = RepoFactory.AnimeEpisode.GetByAniDBEpisodeID(eps[0].EpisodeID)?.Title;
                    cl.AnimeID       = eps[0].AnimeID;
                    SVR_AniDB_Anime anime = RepoFactory.AniDB_Anime.GetByAnimeID(eps[0].AnimeID);
                    if (anime != null)
                    {
                        cl.AnimeName = anime.MainTitle;
                    }
                }
            }

            return(cl);
        }
Пример #4
0
        public string RemoveLinkAniDBForAnime(int animeID, int crossRefType)
        {
            try
            {
                SVR_AniDB_Anime anime = Repo.Instance.AniDB_Anime.GetByID(animeID);

                if (anime == null)
                {
                    return("Could not find Anime!");
                }

                CrossRefType xrefType = (CrossRefType)crossRefType;
                switch (xrefType)
                {
                case CrossRefType.MovieDB:
                    Repo.Instance.AniDB_Anime_DefaultImage.FindAndDelete(() => Repo.Instance.AniDB_Anime_DefaultImage.GetByAnimeID(animeID).Where(a => a.ImageParentType == (int)ImageEntityType.MovieDB_FanArt || a.ImageParentType == (int)ImageEntityType.MovieDB_Poster).ToList());
                    MovieDBHelper.RemoveLinkAniDBMovieDB(animeID);
                    break;

                case CrossRefType.TraktTV:
                    return(RemoveLinkAniDBTraktForAnime(animeID));

                case CrossRefType.TvDB:
                    return(RemoveLinkAniDBTvDBForAnime(animeID));
                }

                return(string.Empty);
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.ToString());
                return(ex.Message);
            }
        }
Пример #5
0
        public static void RemoveAllAniDBTvDBLinks(int animeID, bool updateStats = true)
        {
            // check for Trakt associations
            List <CrossRef_AniDB_TraktV2> trakt = RepoFactory.CrossRef_AniDB_TraktV2.GetByAnimeID(animeID);

            if (trakt.Count != 0)
            {
                foreach (CrossRef_AniDB_TraktV2 a in trakt)
                {
                    RepoFactory.CrossRef_AniDB_TraktV2.Delete(a);
                }
            }

            List <CrossRef_AniDB_TvDB> xrefs = RepoFactory.CrossRef_AniDB_TvDB.GetByAnimeID(animeID);

            if (xrefs == null || xrefs.Count == 0)
            {
                return;
            }

            foreach (CrossRef_AniDB_TvDB xref in xrefs)
            {
                RepoFactory.CrossRef_AniDB_TvDB.Delete(xref);
            }

            if (updateStats)
            {
                SVR_AniDB_Anime.UpdateStatsByAnimeID(animeID);
            }
        }
Пример #6
0
        public static Serie GenerateFromAniDB_Anime(NancyContext ctx, SVR_AniDB_Anime anime, int uid, bool nocast, bool notag, int level, bool all, bool allpics, int pic, TagFilter.Filter tagfilter)
        {
            SVR_AnimeSeries ser = RepoFactory.AnimeSeries.GetByAnimeID(anime.AnimeID) ?? anime.CreateAnimeSeriesAndGroup();
            var             sr  = GenerateFromAnimeSeries(ctx, ser, uid, nocast, notag, level, all, allpics, pic, tagfilter);

            return(sr);
        }
        public override void ProcessCommand()
        {
            logger.Info("Processing CommandRequest_GetAnimeHTTP: {0}", AnimeID);

            try
            {
                SVR_AniDB_Anime anime =
                    ShokoService.AnidbProcessor.GetAnimeInfoHTTP(AnimeID, ForceRefresh, DownloadRelations, RelDepth);

                // NOTE - related anime are downloaded when the relations are created

                // download group status info for this anime
                // the group status will also help us determine missing episodes for a series


                // download reviews
                if (ServerSettings.AniDB_DownloadReviews)
                {
                    CommandRequest_GetReviews cmd = new CommandRequest_GetReviews(AnimeID, ForceRefresh);
                    cmd.Save();
                }

                // Request an image download
            }
            catch (Exception ex)
            {
                logger.Error("Error processing CommandRequest_GetAnimeHTTP: {0} - {1}", AnimeID, ex);
            }
        }
Пример #8
0
        public static void ScanForMatches()
        {
            IReadOnlyList <SVR_AnimeSeries> allSeries = RepoFactory.AnimeSeries.GetAll();

            IReadOnlyList <CrossRef_AniDB_TvDBV2> allCrossRefs = RepoFactory.CrossRef_AniDB_TvDBV2.GetAll();
            List <int> alreadyLinked = allCrossRefs.Select(xref => xref.AnimeID).ToList();

            foreach (SVR_AnimeSeries ser in allSeries)
            {
                if (alreadyLinked.Contains(ser.AniDB_ID))
                {
                    continue;
                }

                SVR_AniDB_Anime anime = ser.GetAnime();

                if (anime != null)
                {
                    if (!anime.GetSearchOnTvDB())
                    {
                        continue;                           // Don't log if it isn't supposed to be there
                    }
                    logger.Trace($"Found anime without tvDB association: {anime.MainTitle}");
                    if (anime.IsTvDBLinkDisabled())
                    {
                        logger.Trace($"Skipping scan tvDB link because it is disabled: {anime.MainTitle}");
                        continue;
                    }
                }

                CommandRequest_TvDBSearchAnime cmd = new CommandRequest_TvDBSearchAnime(ser.AniDB_ID, false);
                cmd.Save();
            }
        }
Пример #9
0
        /// <summary>
        /// Creates an <see cref="SVR_AnimeGroup"/> instance.
        /// </summary>
        /// <remarks>
        /// This method only creates an <see cref="SVR_AnimeGroup"/> instance. It does NOT save it to the database.
        /// </remarks>
        /// <param name="session">The NHibernate session.</param>
        /// <param name="mainSeries">The <see cref="SVR_AnimeSeries"/> whose name will represent the group (Optional. Pass <c>null</c> if not available).</param>
        /// <param name="mainAnimeId">The ID of the anime whose name will represent the group if <paramref name="mainSeries"/> is <c>null</c>.</param>
        /// <param name="now">The current date/time.</param>
        /// <returns>The created <see cref="SVR_AnimeGroup"/>.</returns>
        private SVR_AnimeGroup CreateAnimeGroup(SVR_AnimeSeries mainSeries, int mainAnimeId,
                                                DateTime now)
        {
            SVR_AnimeGroup animeGroup = new SVR_AnimeGroup();
            string         groupName;

            if (mainSeries != null)
            {
                animeGroup.Populate_RA(mainSeries, now);
                groupName = animeGroup.GroupName;
            }
            else // The anime chosen as the group's main anime doesn't actually have a series
            {
                SVR_AniDB_Anime mainAnime = Repo.Instance.AniDB_Anime.GetByAnimeID(mainAnimeId);

                animeGroup.Populate_RA(mainAnime, now);
                groupName = animeGroup.GroupName;
            }

            // If the title appears to end with a year suffix, then remove it
            groupName            = _truncateYearRegex.Replace(groupName, string.Empty);
            animeGroup.GroupName = groupName;
            animeGroup.SortName  = groupName;

            return(animeGroup);
        }
Пример #10
0
        public static void ScanForMatches()
        {
            if (string.IsNullOrEmpty(ServerSettings.MAL_Username) || string.IsNullOrEmpty(ServerSettings.MAL_Password))
            {
                logger.Warn("Won't SCAN MAL, MAL credentials not provided");
                return;
            }

            IReadOnlyList <SVR_AnimeSeries> allSeries = RepoFactory.AnimeSeries.GetAll();

            foreach (SVR_AnimeSeries ser in allSeries)
            {
                SVR_AniDB_Anime anime = ser.GetAnime();
                if (anime == null)
                {
                    continue;
                }

                if (anime.IsMALLinkDisabled())
                {
                    continue;
                }

                // don't scan if it is associated on the TvDB
                List <CrossRef_AniDB_MAL> xrefs = anime.GetCrossRefMAL();
                if (xrefs == null || xrefs.Count == 0)
                {
                    logger.Trace(string.Format("Found anime without MAL association: {0} ({1})", anime.AnimeID,
                                               anime.MainTitle));

                    CommandRequest_MALSearchAnime cmd = new CommandRequest_MALSearchAnime(ser.AniDB_ID, false);
                    cmd.Save();
                }
            }
        }
Пример #11
0
        public string LinkAniDBTvDB(CrossRef_AniDB_TvDBV2 link)
        {
            try
            {
                CrossRef_AniDB_TvDB xref = RepoFactory.CrossRef_AniDB_TvDB.GetByAniDBAndTvDBID(link.AnimeID, link.TvDBID);

                if (xref != null && link.IsAdditive)
                {
                    string          msg   = $"You have already linked Anime ID {xref.AniDBID} to this TvDB show/season/ep";
                    SVR_AniDB_Anime anime = RepoFactory.AniDB_Anime.GetByAnimeID(xref.AniDBID);
                    if (anime != null)
                    {
                        msg =
                            $"You have already linked Anime {anime.MainTitle} ({xref.AniDBID}) to this TvDB show/season/ep";
                    }
                    return(msg);
                }

                // we don't need to proactively remove the link here anymore, as all links are removed when it is not marked as additive
                CommandRequest_LinkAniDBTvDB cmdRequest =
                    new CommandRequest_LinkAniDBTvDB(link.AnimeID, link.TvDBID, link.IsAdditive);
                cmdRequest.Save();

                return(string.Empty);
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.ToString());
                return(ex.Message);
            }
        }
Пример #12
0
        private AniDB_VoteRepository()
        {
            EndSaveCallback = (cr) =>
            {
                switch (cr.VoteType)
                {
                case (int)AniDBVoteType.Anime:
                case (int)AniDBVoteType.AnimeTemp:
                    SVR_AniDB_Anime.UpdateStatsByAnimeID(cr.EntityID);
                    break;

                case (int)AniDBVoteType.Episode:
                    SVR_AnimeEpisode ep = RepoFactory.AnimeEpisode.GetByID(cr.EntityID);
                    RepoFactory.AnimeEpisode.Save(ep);
                    break;
                }
            };
            EndDeleteCallback = (cr) =>
            {
                switch (cr.VoteType)
                {
                case (int)AniDBVoteType.Anime:
                case (int)AniDBVoteType.AnimeTemp:
                    SVR_AniDB_Anime.UpdateStatsByAnimeID(cr.EntityID);
                    break;

                case (int)AniDBVoteType.Episode:
                    SVR_AnimeEpisode ep = RepoFactory.AnimeEpisode.GetByID(cr.EntityID);
                    RepoFactory.AnimeEpisode.Save(ep);
                    break;
                }
            };
        }
Пример #13
0
        public static Serie GenerateFromBookmark(NancyContext ctx, BookmarkedAnime bookmark, int uid, bool nocast, bool notag, int level, bool all, bool allpics, int pic, TagFilter.Filter tagfilter)
        {
            var series = RepoFactory.AnimeSeries.GetByAnimeID(bookmark.AnimeID);

            if (series != null)
            {
                return(GenerateFromAnimeSeries(ctx, series, uid, nocast, notag, level, all, allpics, pic, tagfilter));
            }

            SVR_AniDB_Anime aniDB_Anime = RepoFactory.AniDB_Anime.GetByAnimeID(bookmark.AnimeID);

            if (aniDB_Anime == null)
            {
                Commands.CommandRequest_GetAnimeHTTP cr_anime = new Commands.CommandRequest_GetAnimeHTTP(bookmark.AnimeID, true, false);
                cr_anime.Save();

                Serie empty_serie = new Serie
                {
                    id   = -1,
                    name = "GetAnimeInfoHTTP",
                    aid  = bookmark.AnimeID
                };
                return(empty_serie);
            }
            return(GenerateFromAniDB_Anime(ctx, aniDB_Anime, nocast, notag, allpics, pic, tagfilter));
        }
Пример #14
0
        public override void ProcessCommand()
        {
            logger.Info("Processing CommandRequest_GetReviews: {0}", AnimeID);

            try
            {
                return;

                // we will always assume that an anime was downloaded via http first

                SVR_AniDB_Anime anime = RepoFactory.AniDB_Anime.GetByAnimeID(AnimeID);

                if (anime != null)
                {
                    // reviews count will be 0 when the anime is only downloaded via HTTP
                    if (ForceRefresh || anime.AnimeReviews.Count == 0)
                    {
                        anime = ShokoService.AnidbProcessor.GetAnimeInfoUDP(AnimeID, true);
                    }

                    foreach (AniDB_Anime_Review animeRev in anime.AnimeReviews)
                    {
                        ShokoService.AnidbProcessor.GetReviewUDP(animeRev.ReviewID);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("Error processing CommandRequest_GetReviews: {0} - {1}", AnimeID, ex.ToString());
                return;
            }
        }
        public override void ProcessCommand()
        {
            try
            {
                bool process =
                    ServerSettings.AniDB_Username.Equals("jonbaby", StringComparison.InvariantCultureIgnoreCase) ||
                    ServerSettings.AniDB_Username.Equals("jmediamanager",
                                                         StringComparison.InvariantCultureIgnoreCase) ||
                    ServerSettings.AniDB_Username.Equals("jmmtesting", StringComparison.InvariantCultureIgnoreCase);

                if (!process)
                {
                    return;
                }

                SVR_AniDB_Anime anime = RepoFactory.AniDB_Anime.GetByAnimeID(AnimeID);
                if (anime == null)
                {
                    return;
                }

                if (anime.AllTags.ToUpper().Contains("18 RESTRICTED"))
                {
                    return;
                }

                AzureWebAPI.Send_AnimeFull(anime);
            }
            catch (Exception ex)
            {
                logger.Error("Error processing CommandRequest_Azure_SendAnimeFull: {0} - {1}", AnimeID, ex.ToString());
                return;
            }
        }
Пример #16
0
        public override void ProcessCommand()
        {
            try
            {
                bool process = false;

                if (!process)
                {
                    return;
                }

                SVR_AniDB_Anime anime = RepoFactory.AniDB_Anime.GetByAnimeID(AnimeID);
                if (anime == null)
                {
                    return;
                }

                if (anime.AllTags.ToUpper().Contains("18 RESTRICTED"))
                {
                    return;
                }

                AzureWebAPI.Send_AnimeFull(anime);
            }
            catch (Exception ex)
            {
                logger.Error("Error processing CommandRequest_Azure_SendAnimeFull: {0} - {1}", AnimeID, ex);
            }
        }
Пример #17
0
        public static List <Tag> GetTags(HttpContext ctx, SVR_AniDB_Anime anime, TagFilter.Filter filter, bool excludeDescriptions = false)
        {
            var tags = new List <Tag>();

            var allTags      = anime.GetAniDBTags().DistinctBy(a => a.TagName).ToList();
            var filteredTags = TagFilter.ProcessTags(filter, allTags, tag => tag.TagName);

            foreach (AniDB_Tag tag in filteredTags)
            {
                var toAPI = new Tag
                {
                    Name = tag.TagName
                };
                var animeXRef = RepoFactory.AniDB_Anime_Tag.GetByTagID(tag.TagID).FirstOrDefault();
                if (animeXRef != null)
                {
                    toAPI.Weight = animeXRef.Weight;
                }
                if (!excludeDescriptions)
                {
                    toAPI.Description = tag.TagDescription;
                }

                tags.Add(toAPI);
            }

            return(tags);
        }
Пример #18
0
        public string LinkAniDBTrakt(CL_CrossRef_AniDB_Provider link)
        {
            try
            {
                if (Repo.Instance.CrossRef_AniDB_Provider.GetByAnimeIdAndProvider(CrossRefType.TraktTV, link.AnimeID, link.CrossRefID) != null && link.IsAdditive)
                {
                    string          msg   = $"You have already linked Anime ID {link.AnimeID} to this Trakt show/season/ep";
                    SVR_AniDB_Anime anime = Repo.Instance.AniDB_Anime.GetByID(link.AnimeID);
                    if (anime != null)
                    {
                        msg = $"You have already linked Anime {anime.MainTitle} ({link.AnimeID}) to this Trakt show/season/ep";
                    }
                    return(msg);
                }

                // we don't need to proactively remove the link here anymore, as all links are removed when it is not marked as additive
                CommandQueue.Queue.Instance.Add(new CmdTraktLinkAniDB(link.AnimeID, link.CrossRefID, link.IsAdditive));
                return(string.Empty);
            }
            catch (Exception ex)
            {
                logger.Error(ex, ex.ToString());
                return(ex.Message);
            }
        }
Пример #19
0
        public override void ProcessCommand()
        {
            logger.Info("Processing CommandRequest_MALUpdatedWatchedStatus: {0}", AnimeID);

            try
            {
                // find the latest eps to update
                SVR_AniDB_Anime anime = RepoFactory.AniDB_Anime.GetByAnimeID(AnimeID);
                if (anime == null)
                {
                    return;
                }

                List <CrossRef_AniDB_MAL> crossRefs = anime.GetCrossRefMAL();
                if (crossRefs == null || crossRefs.Count == 0)
                {
                    return;
                }

                SVR_AnimeSeries ser = RepoFactory.AnimeSeries.GetByAnimeID(AnimeID);
                if (ser == null)
                {
                    return;
                }

                MALHelper.UpdateMALSeries(ser);
            }
            catch (Exception ex)
            {
                logger.Error("Error processing CommandRequest_MALUpdatedWatchedStatus: {0} - {1}", AnimeID,
                             ex);
            }
        }
Пример #20
0
        public override void ProcessCommand()
        {
            try
            {
                //if (string.IsNullOrEmpty(ServerSettings.WebCacheAuthKey)) return;

                CrossRef_AniDB_TvDBV2 xref = RepoFactory.CrossRef_AniDB_TvDBV2.GetByID(CrossRef_AniDB_TvDBID);
                if (xref == null)
                {
                    return;
                }

                SVR_AniDB_Anime anime = RepoFactory.AniDB_Anime.GetByAnimeID(xref.AnimeID);
                if (anime == null)
                {
                    return;
                }

                AzureWebAPI.Send_CrossRefAniDBTvDB(xref, anime.MainTitle);
            }
            catch (Exception ex)
            {
                logger.ErrorException("Error processing CommandRequest_WebCacheSendXRefAniDBTvDB: {0}" + ex.ToString(),
                                      ex);
                return;
            }
        }
Пример #21
0
 public static void RemoveAllAniDBTvDBLinks(int animeID, bool updateStats = true)
 {
     Repo.Instance.CrossRef_AniDB_Provider.FindAndDelete(() => Repo.Instance.CrossRef_AniDB_Provider.GetByAnimeIDAndType(animeID, CrossRefType.TvDB));
     if (updateStats)
     {
         SVR_AniDB_Anime.UpdateStatsByAnimeID(animeID);
     }
 }
Пример #22
0
 public static void Populate(this SVR_AnimeGroup agroup, SVR_AniDB_Anime anime, DateTime now)
 {
     agroup.Description     = anime.Description;
     agroup.GroupName       = anime.PreferredTitle;
     agroup.SortName        = anime.PreferredTitle;
     agroup.DateTimeUpdated = now;
     agroup.DateTimeCreated = now;
 }
Пример #23
0
 private AniDB_FileRepository()
 {
     EndDeleteCallback = cr =>
     {
         if (cr.AnimeID > 0)
             SVR_AniDB_Anime.UpdateStatsByAnimeID(cr.AnimeID);
     };
 }
Пример #24
0
 internal override void EndDelete(AniDB_GroupStatus entity, object returnFromBeginDelete, object parameters)
 {
     if (entity.AnimeID != 0)
     {
         logger.Trace("Updating group stats by anime from AniDB_GroupStatusRepository.Delete: {0}", entity.AnimeID);
         SVR_AniDB_Anime.UpdateStatsByAnimeID(entity.AnimeID);
     }
 }
Пример #25
0
 internal override void EndDelete(CrossRef_File_Episode entity, object returnFromBeginDelete, object parameters)
 {
     if (entity != null && entity.AnimeID != 0)
     {
         logger.Trace("Updating group stats by anime from CrossRef_File_EpisodeRepository.Delete: {0}", entity.AnimeID);
         SVR_AniDB_Anime.UpdateStatsByAnimeID(entity.AnimeID);
     }
 }
Пример #26
0
 internal void OnSeriesUpdated(DataSourceEnum source, SVR_AniDB_Anime anime)
 {
     SeriesUpdated?.Invoke(null, new SeriesInfoUpdatedEventArgs
     {
         Type      = source,
         AnimeInfo = anime,
     });
 }
Пример #27
0
        public override void ProcessCommand()
        {
            logger.Info("Get AniDB file info: {0}", VideoLocalID);


            try
            {
                if (vlocal == null)
                {
                    vlocal = RepoFactory.VideoLocal.GetByID(VideoLocalID);
                }
                if (vlocal == null)
                {
                    return;
                }
                lock (vlocal)
                {
                    SVR_AniDB_File aniFile = RepoFactory.AniDB_File.GetByHashAndFileSize(vlocal.Hash, vlocal.FileSize);

                    Raw_AniDB_File fileInfo = null;
                    if (aniFile == null || ForceAniDB)
                    {
                        fileInfo = ShokoService.AnidbProcessor.GetFileInfo(vlocal);
                    }

                    if (fileInfo != null)
                    {
                        // save to the database
                        if (aniFile == null)
                        {
                            aniFile = new SVR_AniDB_File();
                        }

                        SVR_AniDB_File.Populate(aniFile, fileInfo);

                        //overwrite with local file name
                        string localFileName = vlocal.FileName;
                        aniFile.FileName = localFileName;

                        RepoFactory.AniDB_File.Save(aniFile, false);
                        aniFile.CreateLanguages();
                        aniFile.CreateCrossEpisodes(localFileName);

                        SVR_AniDB_Anime anime = RepoFactory.AniDB_Anime.GetByAnimeID(aniFile.AnimeID);
                        if (anime != null)
                        {
                            RepoFactory.AniDB_Anime.Save(anime);
                        }
                        SVR_AnimeSeries series = RepoFactory.AnimeSeries.GetByAnimeID(aniFile.AnimeID);
                        series.UpdateStats(true, true, true);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("Error processing CommandRequest_GetFile: {0} - {1}", VideoLocalID, ex);
            }
        }
Пример #28
0
 internal override object BeginSave(SVR_AniDB_File entity, SVR_AniDB_File original_entity, bool parameters)
 {
     if (parameters) //UpdateStats
     {
         logger.Trace("Updating group stats by file from AniDB_FileRepository.Save: {0}", entity.Hash);
         SVR_AniDB_Anime.UpdateStatsByAnimeID(entity.AnimeID);
     }
     return(null);
 }
Пример #29
0
 public void Save(SVR_AniDB_File obj, bool updateStats)
 {
     base.Save(obj);
     if (updateStats)
     {
         logger.Trace("Updating group stats by file from AniDB_FileRepository.Save: {0}", obj.Hash);
         SVR_AniDB_Anime.UpdateStatsByAnimeID(obj.AnimeID);
     }
 }
Пример #30
0
 internal void OnEpisodeUpdated(DataSourceEnum source, SVR_AniDB_Anime anime, SVR_AnimeEpisode episode)
 {
     EpisodeUpdated?.Invoke(null, new EpisodeInfoUpdatedEventArgs
     {
         Type        = source,
         AnimeInfo   = anime,
         EpisodeInfo = episode,
     });
 }