public override void ProcessCommand() { logger.Info("Processing CommandRequest_MALUploadStatusToMAL"); try { if (string.IsNullOrEmpty(ServerSettings.MAL_Username) || string.IsNullOrEmpty(ServerSettings.MAL_Password)) { return; } // find the latest eps to update AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); List <AniDB_Anime> animes = repAnime.GetAll(); foreach (AniDB_Anime anime in animes) { CommandRequest_MALUpdatedWatchedStatus cmd = new CommandRequest_MALUpdatedWatchedStatus(anime.AnimeID); cmd.Save(); } } catch (Exception ex) { logger.Error("Error processing CommandRequest_MALUploadStatusToMAL: {0}", ex.ToString()); return; } }
public static void RunImport_UpdateAllAniDB() { AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); foreach (AniDB_Anime anime in repAnime.GetAll()) { CommandRequest_GetAnimeHTTP cmd = new CommandRequest_GetAnimeHTTP(anime.AnimeID, true, false); cmd.Save(); } }
public static void RunImport_GetImages() { // AniDB posters AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); foreach (AniDB_Anime anime in repAnime.GetAll()) { if (anime.AnimeID == 8580) Console.Write(""); if (string.IsNullOrEmpty(anime.PosterPath)) continue; bool fileExists = File.Exists(anime.PosterPath); if (!fileExists) { CommandRequest_DownloadImage cmd = new CommandRequest_DownloadImage(anime.AniDB_AnimeID, JMMImageType.AniDB_Cover, false); cmd.Save(); } } // TvDB Posters if (ServerSettings.TvDB_AutoPosters) { TvDB_ImagePosterRepository repTvPosters = new TvDB_ImagePosterRepository(); Dictionary<int, int> postersCount = new Dictionary<int, int>(); // build a dictionary of series and how many images exist List<TvDB_ImagePoster> allPosters = repTvPosters.GetAll(); foreach (TvDB_ImagePoster tvPoster in allPosters) { if (string.IsNullOrEmpty(tvPoster.FullImagePath)) continue; bool fileExists = File.Exists(tvPoster.FullImagePath); if (fileExists) { if (postersCount.ContainsKey(tvPoster.SeriesID)) postersCount[tvPoster.SeriesID] = postersCount[tvPoster.SeriesID] + 1; else postersCount[tvPoster.SeriesID] = 1; } } foreach (TvDB_ImagePoster tvPoster in allPosters) { if (string.IsNullOrEmpty(tvPoster.FullImagePath)) continue; bool fileExists = File.Exists(tvPoster.FullImagePath); int postersAvailable = 0; if (postersCount.ContainsKey(tvPoster.SeriesID)) postersAvailable = postersCount[tvPoster.SeriesID]; if (!fileExists && postersAvailable < ServerSettings.TvDB_AutoPostersAmount) { CommandRequest_DownloadImage cmd = new CommandRequest_DownloadImage(tvPoster.TvDB_ImagePosterID, JMMImageType.TvDB_Cover, false); cmd.Save(); if (postersCount.ContainsKey(tvPoster.SeriesID)) postersCount[tvPoster.SeriesID] = postersCount[tvPoster.SeriesID] + 1; else postersCount[tvPoster.SeriesID] = 1; } } } // TvDB Fanart if (ServerSettings.TvDB_AutoFanart) { Dictionary<int, int> fanartCount = new Dictionary<int, int>(); TvDB_ImageFanartRepository repTvFanart = new TvDB_ImageFanartRepository(); List<TvDB_ImageFanart> allFanart = repTvFanart.GetAll(); foreach (TvDB_ImageFanart tvFanart in allFanart) { // build a dictionary of series and how many images exist if (string.IsNullOrEmpty(tvFanart.FullImagePath)) continue; bool fileExists = File.Exists(tvFanart.FullImagePath); if (fileExists) { if (fanartCount.ContainsKey(tvFanart.SeriesID)) fanartCount[tvFanart.SeriesID] = fanartCount[tvFanart.SeriesID] + 1; else fanartCount[tvFanart.SeriesID] = 1; } } foreach (TvDB_ImageFanart tvFanart in allFanart) { if (string.IsNullOrEmpty(tvFanart.FullImagePath)) continue; bool fileExists = File.Exists(tvFanart.FullImagePath); int fanartAvailable = 0; if (fanartCount.ContainsKey(tvFanart.SeriesID)) fanartAvailable = fanartCount[tvFanart.SeriesID]; if (!fileExists && fanartAvailable < ServerSettings.TvDB_AutoFanartAmount) { CommandRequest_DownloadImage cmd = new CommandRequest_DownloadImage(tvFanart.TvDB_ImageFanartID, JMMImageType.TvDB_FanArt, false); cmd.Save(); if (fanartCount.ContainsKey(tvFanart.SeriesID)) fanartCount[tvFanart.SeriesID] = fanartCount[tvFanart.SeriesID] + 1; else fanartCount[tvFanart.SeriesID] = 1; } } } // TvDB Wide Banners if (ServerSettings.TvDB_AutoWideBanners) { TvDB_ImageWideBannerRepository repTvBanners = new TvDB_ImageWideBannerRepository(); Dictionary<int, int> fanartCount = new Dictionary<int, int>(); // build a dictionary of series and how many images exist List<TvDB_ImageWideBanner> allBanners = repTvBanners.GetAll(); foreach (TvDB_ImageWideBanner tvBanner in allBanners) { if (string.IsNullOrEmpty(tvBanner.FullImagePath)) continue; bool fileExists = File.Exists(tvBanner.FullImagePath); if (fileExists) { if (fanartCount.ContainsKey(tvBanner.SeriesID)) fanartCount[tvBanner.SeriesID] = fanartCount[tvBanner.SeriesID] + 1; else fanartCount[tvBanner.SeriesID] = 1; } } foreach (TvDB_ImageWideBanner tvBanner in allBanners) { if (string.IsNullOrEmpty(tvBanner.FullImagePath)) continue; bool fileExists = File.Exists(tvBanner.FullImagePath); int bannersAvailable = 0; if (fanartCount.ContainsKey(tvBanner.SeriesID)) bannersAvailable = fanartCount[tvBanner.SeriesID]; if (!fileExists && bannersAvailable < ServerSettings.TvDB_AutoWideBannersAmount) { CommandRequest_DownloadImage cmd = new CommandRequest_DownloadImage(tvBanner.TvDB_ImageWideBannerID, JMMImageType.TvDB_Banner, false); cmd.Save(); if (fanartCount.ContainsKey(tvBanner.SeriesID)) fanartCount[tvBanner.SeriesID] = fanartCount[tvBanner.SeriesID] + 1; else fanartCount[tvBanner.SeriesID] = 1; } } } // TvDB Episodes TvDB_EpisodeRepository repTvEpisodes = new TvDB_EpisodeRepository(); foreach (TvDB_Episode tvEpisode in repTvEpisodes.GetAll()) { if (string.IsNullOrEmpty(tvEpisode.FullImagePath)) continue; bool fileExists = File.Exists(tvEpisode.FullImagePath); if (!fileExists) { CommandRequest_DownloadImage cmd = new CommandRequest_DownloadImage(tvEpisode.TvDB_EpisodeID, JMMImageType.TvDB_Episode, false); cmd.Save(); } } // MovieDB Posters if (ServerSettings.MovieDB_AutoPosters) { MovieDB_PosterRepository repMoviePosters = new MovieDB_PosterRepository(); Dictionary<int, int> postersCount = new Dictionary<int, int>(); // build a dictionary of series and how many images exist List<MovieDB_Poster> allPosters = repMoviePosters.GetAll(); foreach (MovieDB_Poster moviePoster in allPosters) { if (string.IsNullOrEmpty(moviePoster.FullImagePath)) continue; bool fileExists = File.Exists(moviePoster.FullImagePath); if (fileExists) { if (postersCount.ContainsKey(moviePoster.MovieId)) postersCount[moviePoster.MovieId] = postersCount[moviePoster.MovieId] + 1; else postersCount[moviePoster.MovieId] = 1; } } foreach (MovieDB_Poster moviePoster in allPosters) { if (string.IsNullOrEmpty(moviePoster.FullImagePath)) continue; bool fileExists = File.Exists(moviePoster.FullImagePath); int postersAvailable = 0; if (postersCount.ContainsKey(moviePoster.MovieId)) postersAvailable = postersCount[moviePoster.MovieId]; if (!fileExists && postersAvailable < ServerSettings.MovieDB_AutoPostersAmount) { CommandRequest_DownloadImage cmd = new CommandRequest_DownloadImage(moviePoster.MovieDB_PosterID, JMMImageType.MovieDB_Poster, false); cmd.Save(); if (postersCount.ContainsKey(moviePoster.MovieId)) postersCount[moviePoster.MovieId] = postersCount[moviePoster.MovieId] + 1; else postersCount[moviePoster.MovieId] = 1; } } } // MovieDB Fanart if (ServerSettings.MovieDB_AutoFanart) { MovieDB_FanartRepository repMovieFanarts = new MovieDB_FanartRepository(); Dictionary<int, int> fanartCount = new Dictionary<int, int>(); // build a dictionary of series and how many images exist List<MovieDB_Fanart> allFanarts = repMovieFanarts.GetAll(); foreach (MovieDB_Fanart movieFanart in allFanarts) { if (string.IsNullOrEmpty(movieFanart.FullImagePath)) continue; bool fileExists = File.Exists(movieFanart.FullImagePath); if (fileExists) { if (fanartCount.ContainsKey(movieFanart.MovieId)) fanartCount[movieFanart.MovieId] = fanartCount[movieFanart.MovieId] + 1; else fanartCount[movieFanart.MovieId] = 1; } } foreach (MovieDB_Fanart movieFanart in repMovieFanarts.GetAll()) { if (string.IsNullOrEmpty(movieFanart.FullImagePath)) continue; bool fileExists = File.Exists(movieFanart.FullImagePath); int fanartAvailable = 0; if (fanartCount.ContainsKey(movieFanart.MovieId)) fanartAvailable = fanartCount[movieFanart.MovieId]; if (!fileExists && fanartAvailable < ServerSettings.MovieDB_AutoFanartAmount) { CommandRequest_DownloadImage cmd = new CommandRequest_DownloadImage(movieFanart.MovieDB_FanartID, JMMImageType.MovieDB_FanArt, false); cmd.Save(); if (fanartCount.ContainsKey(movieFanart.MovieId)) fanartCount[movieFanart.MovieId] = fanartCount[movieFanart.MovieId] + 1; else fanartCount[movieFanart.MovieId] = 1; } } } // Trakt Posters if (ServerSettings.Trakt_DownloadPosters) { Trakt_ImagePosterRepository repTraktPosters = new Trakt_ImagePosterRepository(); foreach (Trakt_ImagePoster traktPoster in repTraktPosters.GetAll()) { if (string.IsNullOrEmpty(traktPoster.FullImagePath)) continue; bool fileExists = File.Exists(traktPoster.FullImagePath); if (!fileExists) { CommandRequest_DownloadImage cmd = new CommandRequest_DownloadImage(traktPoster.Trakt_ImagePosterID, JMMImageType.Trakt_Poster, false); cmd.Save(); } } } // Trakt Fanart if (ServerSettings.Trakt_DownloadFanart) { Trakt_ImageFanartRepository repTraktFanarts = new Trakt_ImageFanartRepository(); foreach (Trakt_ImageFanart traktFanart in repTraktFanarts.GetAll()) { if (string.IsNullOrEmpty(traktFanart.FullImagePath)) continue; bool fileExists = File.Exists(traktFanart.FullImagePath); if (!fileExists) { CommandRequest_DownloadImage cmd = new CommandRequest_DownloadImage(traktFanart.Trakt_ImageFanartID, JMMImageType.Trakt_Fanart, false); cmd.Save(); } } } // Trakt Episode if (ServerSettings.Trakt_DownloadEpisodes) { Trakt_EpisodeRepository repTraktEpisodes = new Trakt_EpisodeRepository(); foreach (Trakt_Episode traktEp in repTraktEpisodes.GetAll()) { if (string.IsNullOrEmpty(traktEp.FullImagePath)) continue; if (!traktEp.TraktID.HasValue) continue; // if it doesn't have a TraktID it means it is old data bool fileExists = File.Exists(traktEp.FullImagePath); if (!fileExists) { CommandRequest_DownloadImage cmd = new CommandRequest_DownloadImage(traktEp.Trakt_EpisodeID, JMMImageType.Trakt_Episode, false); cmd.Save(); } } } // AniDB Characters if (ServerSettings.AniDB_DownloadCharacters) { AniDB_CharacterRepository repChars = new AniDB_CharacterRepository(); foreach (AniDB_Character chr in repChars.GetAll()) { if (chr.CharID == 75250) { Console.WriteLine("test"); } if (string.IsNullOrEmpty(chr.PosterPath)) continue; bool fileExists = File.Exists(chr.PosterPath); if (!fileExists) { CommandRequest_DownloadImage cmd = new CommandRequest_DownloadImage(chr.AniDB_CharacterID, JMMImageType.AniDB_Character, false); cmd.Save(); } } } // AniDB Creators if (ServerSettings.AniDB_DownloadCreators) { AniDB_SeiyuuRepository repSeiyuu = new AniDB_SeiyuuRepository(); foreach (AniDB_Seiyuu seiyuu in repSeiyuu.GetAll()) { if (string.IsNullOrEmpty(seiyuu.PosterPath)) continue; bool fileExists = File.Exists(seiyuu.PosterPath); if (!fileExists) { CommandRequest_DownloadImage cmd = new CommandRequest_DownloadImage(seiyuu.AniDB_SeiyuuID, JMMImageType.AniDB_Creator, false); cmd.Save(); } } } }