public string UpdateMovieDBData(int movieD) { try { MovieDBHelper.UpdateMovieInfo(movieD, true); } catch (Exception ex) { logger.Error(ex, ex.ToString()); } return(string.Empty); }
private bool ProcessSearchResults(ISession session, List <MovieDB_Movie_Result> results, string searchCriteria) { if (results.Count == 1) { // since we are using this result, lets download the info logger.Trace("Found 1 moviedb results for search on {0} --- Linked to {1} ({2})", searchCriteria, results[0].MovieName, results[0].MovieID); int movieID = results[0].MovieID; MovieDBHelper.UpdateMovieInfo(session, movieID, true); MovieDBHelper.LinkAniDBMovieDB(AnimeID, movieID, false); return(true); } return(false); }
public override void ProcessCommand() { logger.Info("Processing CommandRequest_MovieDBSearchAnime: {0}", AnimeID); try { using (var session = DatabaseFactory.SessionFactory.OpenSession()) { ISessionWrapper sessionWrapper = session.Wrap(); // first check if the user wants to use the web cache if (ServerSettings.Instance.WebCache.Enabled && ServerSettings.Instance.WebCache.TvDB_Get) { try { Azure_CrossRef_AniDB_Other crossRef = AzureWebAPI.Get_CrossRefAniDBOther(AnimeID, CrossRefType.MovieDB); if (crossRef != null) { int movieID = int.Parse(crossRef.CrossRefID); MovieDB_Movie movie = RepoFactory.MovieDb_Movie.GetByOnlineID(sessionWrapper, movieID); if (movie == null) { // update the info from online MovieDBHelper.UpdateMovieInfo(session, movieID, true); movie = RepoFactory.MovieDb_Movie.GetByOnlineID(movieID); } if (movie != null) { // since we are using the web cache result, let's save it MovieDBHelper.LinkAniDBMovieDB(AnimeID, movieID, true); return; } } } catch (Exception) { } } // Use TvDB setting if (!ServerSettings.Instance.TvDB.AutoLink) { return; } string searchCriteria = string.Empty; SVR_AniDB_Anime anime = RepoFactory.AniDB_Anime.GetByAnimeID(sessionWrapper, AnimeID); if (anime == null) { return; } searchCriteria = anime.MainTitle; // if not wanting to use web cache, or no match found on the web cache go to TvDB directly List <MovieDB_Movie_Result> results = MovieDBHelper.Search(searchCriteria); logger.Trace("Found {0} moviedb results for {1} on TheTvDB", results.Count, searchCriteria); if (ProcessSearchResults(session, results, searchCriteria)) { return; } if (results.Count == 0) { foreach (AniDB_Anime_Title title in anime.GetTitles()) { if (title.TitleType.ToUpper() != Shoko.Models.Constants.AnimeTitleType.Official.ToUpper()) { continue; } if (searchCriteria.ToUpper() == title.Title.ToUpper()) { continue; } results = MovieDBHelper.Search(title.Title); logger.Trace("Found {0} moviedb results for search on {1}", results.Count, title.Title); if (ProcessSearchResults(session, results, title.Title)) { return; } } } } } catch (Exception ex) { logger.Error("Error processing CommandRequest_TvDBSearchAnime: {0} - {1}", AnimeID, ex); } }
public override void ProcessCommand() { logger.Info("Processing CommandRequest_MovieDBSearchAnime: {0}", AnimeID); try { using (var session = JMMService.SessionFactory.OpenSession()) { // first check if the user wants to use the web cache if (ServerSettings.WebCache_TvDB_Get) { try { MovieDB_MovieRepository repMovies = new MovieDB_MovieRepository(); JMMServer.Providers.Azure.CrossRef_AniDB_Other crossRef = JMMServer.Providers.Azure.AzureWebAPI.Get_CrossRefAniDBOther(AnimeID, CrossRefType.MovieDB); if (crossRef != null) { int movieID = int.Parse(crossRef.CrossRefID); MovieDB_Movie movie = repMovies.GetByOnlineID(session, movieID); if (movie == null) { // update the info from online MovieDBHelper.UpdateMovieInfo(session, movieID, true); movie = repMovies.GetByOnlineID(movieID); } if (movie != null) { // since we are using the web cache result, let's save it MovieDBHelper.LinkAniDBMovieDB(AnimeID, movieID, true); return; } } } catch (Exception) { } } string searchCriteria = ""; AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); AniDB_Anime anime = repAnime.GetByAnimeID(session, AnimeID); if (anime == null) { return; } searchCriteria = anime.MainTitle; // if not wanting to use web cache, or no match found on the web cache go to TvDB directly List <MovieDB_Movie_Result> results = MovieDBHelper.Search(searchCriteria); logger.Trace("Found {0} moviedb results for {1} on TheTvDB", results.Count, searchCriteria); if (ProcessSearchResults(session, results, searchCriteria)) { return; } if (results.Count == 0) { foreach (AniDB_Anime_Title title in anime.GetTitles(session)) { if (title.TitleType.ToUpper() != Constants.AnimeTitleType.Official.ToUpper()) { continue; } if (searchCriteria.ToUpper() == title.Title.ToUpper()) { continue; } results = MovieDBHelper.Search(title.Title); logger.Trace("Found {0} moviedb results for search on {1}", results.Count, title.Title); if (ProcessSearchResults(session, results, title.Title)) { return; } } } } } catch (Exception ex) { logger.Error("Error processing CommandRequest_TvDBSearchAnime: {0} - {1}", AnimeID, ex.ToString()); return; } }
public override void Run(IProgress <ICommand> progress = null) { logger.Info("Processing CommandRequest_MovieDBSearchAnime: {0}", AnimeID); try { { ReportInit(progress); // first check if the user wants to use the web cache if (ServerSettings.Instance.WebCache.TvDB_Get) { try { List <WebCache_CrossRef_AniDB_Provider> resultsCache = WebCacheAPI.Instance.GetCrossRef_AniDB_Provider(AnimeID, CrossRefType.MovieDB); ReportUpdate(progress, 30); if (resultsCache != null && resultsCache.Count > 0) { List <WebCache_CrossRef_AniDB_Provider> best = resultsCache.BestProvider(); if (best.Count > 0) { int movieID = int.Parse(best.First().CrossRefID); MovieDB_Movie movie = Repo.Instance.MovieDb_Movie.GetByOnlineID(movieID); if (movie == null) { // update the info from online MovieDBHelper.UpdateMovieInfo(movieID, true); movie = Repo.Instance.MovieDb_Movie.GetByOnlineID(movieID); } ReportUpdate(progress, 20); if (movie != null) { // since we are using the web cache result, let's save it MovieDBHelper.LinkAniDBMovieDB(AnimeID, movieID, true); ReportFinish(progress); return; } return; } } } catch (Exception) { //Ignore } } // Use TvDB setting if (!ServerSettings.Instance.TvDB.AutoLink) { ReportFinish(progress); return; } ReportUpdate(progress, 40); SVR_AniDB_Anime anime = Repo.Instance.AniDB_Anime.GetByAnimeID(AnimeID); if (anime == null) { ReportFinish(progress); return; } string searchCriteria = anime.MainTitle; // if not wanting to use web cache, or no match found on the web cache go to TvDB directly List <MovieDB_Movie_Result> results = MovieDBHelper.Search(searchCriteria); logger.Trace("Found {0} moviedb results for {1} on TheTvDB", results.Count, searchCriteria); ReportUpdate(progress, 60); if (ProcessSearchResults(results, searchCriteria)) { ReportFinish(progress); return; } ReportUpdate(progress, 80); if (results.Count == 0) { foreach (AniDB_Anime_Title title in anime.GetTitles()) { if (!string.Equals(title.TitleType, Shoko.Models.Constants.AnimeTitleType.Official, StringComparison.OrdinalIgnoreCase)) { continue; } if (string.Equals(searchCriteria, title.Title, StringComparison.OrdinalIgnoreCase)) { continue; } results = MovieDBHelper.Search(title.Title); logger.Trace("Found {0} moviedb results for search on {1}", results.Count, title.Title); if (ProcessSearchResults(results, title.Title)) { ReportFinish(progress); return; } } } ReportFinish(progress); } } catch (Exception ex) { ReportError(progress, $"Error processing CommandRequest_TvDBSearchAnime: {AnimeID} - {ex}", ex); } }