Example #1
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.GetIsMALLinkDisabled())
                {
                    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();
                }
            }
        }