public override void ProcessCommand() { logger.Info("Processing CommandRequest_MALUpdatedWatchedStatus: {0}", AnimeID); try { // find the latest eps to update AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); AniDB_Anime anime = repAnime.GetByAnimeID(AnimeID); if (anime == null) return; List<CrossRef_AniDB_MAL> crossRefs = anime.GetCrossRefMAL(); if (crossRefs == null || crossRefs.Count == 0) return; AnimeSeriesRepository repSeries = new AnimeSeriesRepository(); AnimeSeries ser = repSeries.GetByAnimeID(AnimeID); if (ser == null) return; MALHelper.UpdateMALSeries(ser); } catch (Exception ex) { logger.Error("Error processing CommandRequest_MALUpdatedWatchedStatus: {0} - {1}", AnimeID, ex.ToString()); return; } }
public static void InitCache() { string t = "AniDB_Anime"; ServerState.Instance.CurrentSetupStatus = string.Format(JMMServer.Properties.Resources.Database_Cache, t, string.Empty); AniDB_AnimeRepository repo = new AniDB_AnimeRepository(); using (var session = JMMService.SessionFactory.OpenSession()) { List <AniDB_Anime> ls = repo.GetAll(session).Where(a => a.ContractVersion < AniDB_Anime.CONTRACT_VERSION).ToList(); int max = ls.Count; int cnt = 0; foreach (AniDB_Anime a in ls) { repo.Save(session, a); cnt++; if (cnt % 10 == 0) { ServerState.Instance.CurrentSetupStatus = string.Format(JMMServer.Properties.Resources.Database_Cache, t, " DbRegen - " + cnt + "/" + max); } } ServerState.Instance.CurrentSetupStatus = string.Format(JMMServer.Properties.Resources.Database_Cache, t, " DbRegen - " + max + "/" + max); } }
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; AniDB_AnimeRepository rep = new AniDB_AnimeRepository(); AniDB_Anime anime = rep.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; } }
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 override void ProcessCommand() { logger.Info("Processing CommandRequest_GetReviews: {0}", AnimeID); try { return; // we will always assume that an anime was downloaded via http first AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); AniDB_Anime anime = repAnime.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 = JMMService.AnidbProcessor.GetAnimeInfoUDP(AnimeID, true); foreach (AniDB_Anime_Review animeRev in anime.AnimeReviews) { JMMService.AnidbProcessor.GetReviewUDP(animeRev.ReviewID); } } } catch (Exception ex) { logger.Error("Error processing CommandRequest_GetReviews: {0} - {1}", AnimeID, ex.ToString()); return; } }
public override void ProcessCommand() { try { CrossRef_AniDB_TraktV2Repository repCrossRef = new CrossRef_AniDB_TraktV2Repository(); CrossRef_AniDB_TraktV2 xref = repCrossRef.GetByID(CrossRef_AniDB_TraktID); if (xref == null) return; Trakt_ShowRepository repShow = new Trakt_ShowRepository(); Trakt_Show tvShow = repShow.GetByTraktSlug(xref.TraktID); if (tvShow == null) return; AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); AniDB_Anime anime = repAnime.GetByAnimeID(xref.AnimeID); if (anime == null) return; string showName = ""; if (tvShow != null) showName = tvShow.Title; AzureWebAPI.Send_CrossRefAniDBTrakt(xref, anime.MainTitle); } catch (Exception ex) { logger.ErrorException("Error processing CommandRequest_WebCacheSendXRefAniDBTrakt: {0}" + ex.ToString(), ex); return; } }
public override void ProcessCommand() { logger.Info("Processing CommandRequest_GetAnimeHTTP: {0}", AnimeID); try { AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); AniDB_Anime anime = JMMService.AnidbProcessor.GetAnimeInfoHTTP(AnimeID, ForceRefresh, DownloadRelations); // 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.ToString()); return; } }
public MetroContract_CommunityLinks GetCommunityLinks(int animeID) { MetroContract_CommunityLinks contract = new MetroContract_CommunityLinks(); try { using (var session = JMMService.SessionFactory.OpenSession()) { AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); AniDB_Anime anime = repAnime.GetByAnimeID(session, animeID); if (anime == null) return null; //AniDB contract.AniDB_ID = animeID; contract.AniDB_URL = string.Format(Constants.URLS.AniDB_Series, animeID); contract.AniDB_DiscussURL = string.Format(Constants.URLS.AniDB_SeriesDiscussion, animeID); // MAL List<CrossRef_AniDB_MAL> malRef = anime.GetCrossRefMAL(session); if (malRef != null && malRef.Count > 0) { contract.MAL_ID = malRef[0].MALID.ToString(); contract.MAL_URL = string.Format(Constants.URLS.MAL_Series, malRef[0].MALID); //contract.MAL_DiscussURL = string.Format(Constants.URLS.MAL_SeriesDiscussion, malRef[0].MALID, malRef[0].MALTitle); contract.MAL_DiscussURL = string.Format(Constants.URLS.MAL_Series, malRef[0].MALID); } // TvDB List<CrossRef_AniDB_TvDBV2> tvdbRef = anime.GetCrossRefTvDBV2(session); if (tvdbRef != null && tvdbRef.Count > 0) { contract.TvDB_ID = tvdbRef[0].TvDBID.ToString(); contract.TvDB_URL = string.Format(Constants.URLS.TvDB_Series, tvdbRef[0].TvDBID); } // Trakt List<CrossRef_AniDB_TraktV2> traktRef = anime.GetCrossRefTraktV2(session); if (traktRef != null && traktRef.Count > 0) { contract.Trakt_ID = traktRef[0].TraktID; contract.Trakt_URL = string.Format(Constants.URLS.Trakt_Series, traktRef[0].TraktID); } } } catch (Exception ex) { logger.ErrorException(ex.ToString(), ex); } return contract; }
public Contract_IgnoreAnime ToContract() { Contract_IgnoreAnime contract = new Contract_IgnoreAnime(); contract.IgnoreAnimeID = this.IgnoreAnimeID; contract.JMMUserID = this.JMMUserID; contract.AnimeID = this.AnimeID; contract.IgnoreType = this.IgnoreType; AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); AniDB_Anime anime = repAnime.GetByAnimeID(AnimeID); if (anime != null) contract.Anime = anime.ToContract(); return contract; }
public override void ProcessCommand() { try { bool process = (ServerSettings.AniDB_Username.Equals("jonbaby", StringComparison.InvariantCultureIgnoreCase) || ServerSettings.AniDB_Username.Equals("jmediamanager", StringComparison.InvariantCultureIgnoreCase)); if (!process) return; AniDB_AnimeRepository rep = new AniDB_AnimeRepository(); AniDB_Anime anime = rep.GetByAnimeID(AnimeID); if (anime == null) return; string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string filePath = Path.Combine(appPath, "Anime_HTTP"); if (!Directory.Exists(filePath)) Directory.CreateDirectory(filePath); string fileName = string.Format("AnimeDoc_{0}.xml", AnimeID); string fileNameWithPath = Path.Combine(filePath, fileName); string rawXML = ""; if (File.Exists(fileNameWithPath)) { StreamReader re = File.OpenText(fileNameWithPath); rawXML = re.ReadToEnd(); re.Close(); } AnimeXML xml = new AnimeXML(); xml.AnimeID = AnimeID; xml.AnimeName = anime.MainTitle; xml.DateDownloaded = 0; xml.Username = ServerSettings.AniDB_Username; xml.XMLContent = rawXML; AzureWebAPI.Send_AnimeXML(xml); } catch (Exception ex) { logger.Error("Error processing CommandRequest_Azure_SendAnimeXML: {0} - {1}", AnimeID, ex.ToString()); return; } }
public Contract_BookmarkedAnime ToContract() { Contract_BookmarkedAnime contract = new Contract_BookmarkedAnime(); contract.BookmarkedAnimeID = BookmarkedAnimeID; contract.AnimeID = AnimeID; contract.Priority = Priority; contract.Notes = Notes; contract.Downloading = Downloading; contract.Anime = null; AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); AniDB_Anime an = repAnime.GetByAnimeID(AnimeID); if (an != null) contract.Anime = an.ToContract(true, null); return contract; }
public bool HasTraktLink(int animeID) { try { AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); AniDB_Anime anime = repAnime.GetByAnimeID(animeID); if (anime == null) return false; return anime.GetCrossRefTrakt() != null; } catch (Exception ex) { logger.ErrorException(ex.ToString(), ex); } return false; }
public override void ProcessCommand() { logger.Info("Processing CommandRequest_GetCharactersCreators: {0}", AnimeID); try { AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); AniDB_Character_CreatorRepository repCharCreators = new AniDB_Character_CreatorRepository(); AniDB_Anime anime = null; if (ForceRefresh) { // redownload anime details from http ap so we can get an update character list anime = JMMService.AnidbProcessor.GetAnimeInfoHTTP(AnimeID, false, false); } else anime = repAnime.GetByAnimeID(AnimeID); if (anime == null) return; foreach (AniDB_Anime_Character animeChar in anime.AnimeCharacters) { //MainWindow.anidbProcessor.UpdateCharacterInfo(charref.CharID, false); //logger.Trace("Downloading char info: {0}", animeChar.CharID); CommandRequest_GetCharacter cmdChar = new CommandRequest_GetCharacter(animeChar.CharID, ForceRefresh); cmdChar.Save(); // for each of the creators for this character foreach (AniDB_Character_Seiyuu aac in repCharCreators.GetByCharID(animeChar.CharID)) { CommandRequest_GetCreator cmdCreators = new CommandRequest_GetCreator(aac.SeiyuuID, ForceRefresh); cmdCreators.Save(); } } } catch (Exception ex) { logger.Error("Error processing CommandRequest_GetCharactersCreators: {0} - {1}", AnimeID, ex.ToString()); return; } }
public override void ProcessCommand() { try { //if (string.IsNullOrEmpty(ServerSettings.WebCacheAuthKey)) return; CrossRef_AniDB_TvDBV2Repository repCrossRef = new CrossRef_AniDB_TvDBV2Repository(); CrossRef_AniDB_TvDBV2 xref = repCrossRef.GetByID(CrossRef_AniDB_TvDBID); if (xref == null) return; AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); AniDB_Anime anime = repAnime.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; } }
public static void SyncCollectionToTrakt() { try { if (!ServerSettings.Trakt_IsEnabled || string.IsNullOrEmpty(ServerSettings.Trakt_AuthToken)) return; // check that we have at least one user nominated for Trakt JMMUserRepository repUsers = new JMMUserRepository(); List<JMMUser> traktUsers = repUsers.GetTraktUsers(); if (traktUsers.Count == 0) return; AnimeSeriesRepository repSeries = new AnimeSeriesRepository(); List<AnimeSeries> allSeries = repSeries.GetAll(); // now get the full users collection from Trakt List<TraktV2ShowCollectedResult> collected = new List<TraktV2ShowCollectedResult>(); List<TraktV2ShowWatchedResult> watched = new List<TraktV2ShowWatchedResult>(); if (!GetTraktCollectionInfo(ref collected, ref watched)) return; TraktV2SyncCollectionEpisodesByNumber syncCollectionAdd = new TraktV2SyncCollectionEpisodesByNumber(); TraktV2SyncCollectionEpisodesByNumber syncCollectionRemove = new TraktV2SyncCollectionEpisodesByNumber(); TraktV2SyncWatchedEpisodesByNumber syncHistoryAdd = new TraktV2SyncWatchedEpisodesByNumber(); TraktV2SyncWatchedEpisodesByNumber syncHistoryRemove = new TraktV2SyncWatchedEpisodesByNumber(); #region Local Collection Sync /////////////////////////////////////////////////////////////////////////////////////// // First take a look at our local collection and update on Trakt /////////////////////////////////////////////////////////////////////////////////////// AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); int counter = 0; foreach (AnimeSeries series in allSeries) { counter++; logger.Trace("Syncing check - local collection: {0} / {1} - {2}", counter, allSeries.Count, series.GetSeriesName()); AniDB_Anime anime = repAnime.GetByAnimeID(series.AniDB_ID); if (anime == null) continue; //if (anime.AnimeID != 3427) continue; TraktSummaryContainer traktSummary = new TraktSummaryContainer(); traktSummary.Populate(series.AniDB_ID); if (traktSummary.CrossRefTraktV2 == null || traktSummary.CrossRefTraktV2.Count == 0) continue; // get the current watched records for this series on Trakt foreach (AnimeEpisode ep in series.GetAnimeEpisodes()) { if (ep.EpisodeTypeEnum == enEpisodeType.Episode || ep.EpisodeTypeEnum == enEpisodeType.Special) { EpisodeSyncDetails epsync = ReconSyncTraktEpisode(series, ep, traktSummary, traktUsers, collected, watched, false); if (epsync != null) { switch (epsync.SyncType) { case TraktSyncType.CollectionAdd: syncCollectionAdd.AddEpisode(epsync.Slug, epsync.Season, epsync.EpNumber, epsync.EpDate); break; case TraktSyncType.CollectionRemove: syncCollectionRemove.AddEpisode(epsync.Slug, epsync.Season, epsync.EpNumber, epsync.EpDate); break; case TraktSyncType.HistoryAdd: syncHistoryAdd.AddEpisode(epsync.Slug, epsync.Season, epsync.EpNumber, epsync.EpDate); break; case TraktSyncType.HistoryRemove: syncHistoryRemove.AddEpisode(epsync.Slug, epsync.Season, epsync.EpNumber, epsync.EpDate); break; } } } } } #endregion // refresh online info, just in case it was chnaged by the last operations if (!GetTraktCollectionInfo(ref collected, ref watched)) return; #region Online Collection Sync /////////////////////////////////////////////////////////////////////////////////////// // Now look at the collection according to Trakt, and remove it if we don't have it locally /////////////////////////////////////////////////////////////////////////////////////// CrossRef_AniDB_TraktV2Repository repCrossRef = new CrossRef_AniDB_TraktV2Repository(); counter = 0; foreach (TraktV2ShowCollectedResult col in collected) { counter++; logger.Trace("Syncing check - Online collection: {0} / {1} - {2}", counter, collected.Count, col.show.Title); //continue; // check if we have this series locally List<CrossRef_AniDB_TraktV2> xrefs = repCrossRef.GetByTraktID(col.show.ids.slug); if (xrefs.Count > 0) { foreach (CrossRef_AniDB_TraktV2 xref in xrefs) { AnimeSeries locSeries = repSeries.GetByAnimeID(xref.AnimeID); if (locSeries == null) continue; TraktSummaryContainer traktSummary = new TraktSummaryContainer(); traktSummary.Populate(locSeries.AniDB_ID); if (traktSummary.CrossRefTraktV2 == null || traktSummary.CrossRefTraktV2.Count == 0) continue; // if we have this series locSeries, let's sync the whole series foreach (AnimeEpisode ep in locSeries.GetAnimeEpisodes()) { if (ep.EpisodeTypeEnum == enEpisodeType.Episode || ep.EpisodeTypeEnum == enEpisodeType.Special) { EpisodeSyncDetails epsync = ReconSyncTraktEpisode(locSeries, ep, traktSummary, traktUsers, collected, watched, false); if (epsync != null) { switch (epsync.SyncType) { case TraktSyncType.CollectionAdd: syncCollectionAdd.AddEpisode(epsync.Slug, epsync.Season, epsync.EpNumber, epsync.EpDate); break; case TraktSyncType.CollectionRemove: syncCollectionRemove.AddEpisode(epsync.Slug, epsync.Season, epsync.EpNumber, epsync.EpDate); break; case TraktSyncType.HistoryAdd: syncHistoryAdd.AddEpisode(epsync.Slug, epsync.Season, epsync.EpNumber, epsync.EpDate); break; case TraktSyncType.HistoryRemove: syncHistoryRemove.AddEpisode(epsync.Slug, epsync.Season, epsync.EpNumber, epsync.EpDate); break; } } } } } } else { // Actually we can't do this, because the user may have other non Anime series and Movies /* // series doesn't exist locally at all, so let's completely remove it from Trakt foreach (TraktV2CollectedSeason colSeason in col.seasons) { foreach (TraktV2CollectedEpisode colEp in colSeason.episodes) { string msg = string.Format("SYNC ONLINE: Removing from Trakt Collection: Slug: {0} - S:{1} - EP:{2}", col.show.ids.slug, colSeason.number, colEp.number); logger.Trace(msg); SyncEpisodeToTrakt(TraktSyncType.CollectionRemove, col.show.ids.slug, colSeason.number, colEp.number, DateTime.Now, false); } }*/ } } #endregion // refresh online info, just in case it was chnaged by the last operations if (!GetTraktCollectionInfo(ref collected, ref watched)) return; #region Online History (Watched/Unwatched) Sync /////////////////////////////////////////////////////////////////////////////////////// // Now look at the history according to Trakt, and remove it if we don't have it locally /////////////////////////////////////////////////////////////////////////////////////// counter = 0; foreach (TraktV2ShowWatchedResult wtch in watched) { counter++; logger.Trace("Syncing check - Online History: {0} / {1} - {2}", counter, watched.Count, wtch.show.Title); //continue; // check if we have this series locally List<CrossRef_AniDB_TraktV2> xrefs = repCrossRef.GetByTraktID(wtch.show.ids.slug); if (xrefs.Count > 0) { foreach (CrossRef_AniDB_TraktV2 xref in xrefs) { AnimeSeries locSeries = repSeries.GetByAnimeID(xref.AnimeID); if (locSeries == null) continue; TraktSummaryContainer traktSummary = new TraktSummaryContainer(); traktSummary.Populate(locSeries.AniDB_ID); if (traktSummary.CrossRefTraktV2 == null || traktSummary.CrossRefTraktV2.Count == 0) continue; // if we have this series locSeries, let's sync the whole series foreach (AnimeEpisode ep in locSeries.GetAnimeEpisodes()) { if (ep.EpisodeTypeEnum == enEpisodeType.Episode || ep.EpisodeTypeEnum == enEpisodeType.Special) { EpisodeSyncDetails epsync = ReconSyncTraktEpisode(locSeries, ep, traktSummary, traktUsers, collected, watched, false); if (epsync != null) { switch (epsync.SyncType) { case TraktSyncType.CollectionAdd: syncCollectionAdd.AddEpisode(epsync.Slug, epsync.Season, epsync.EpNumber, epsync.EpDate); break; case TraktSyncType.CollectionRemove: syncCollectionRemove.AddEpisode(epsync.Slug, epsync.Season, epsync.EpNumber, epsync.EpDate); break; case TraktSyncType.HistoryAdd: syncHistoryAdd.AddEpisode(epsync.Slug, epsync.Season, epsync.EpNumber, epsync.EpDate); break; case TraktSyncType.HistoryRemove: syncHistoryRemove.AddEpisode(epsync.Slug, epsync.Season, epsync.EpNumber, epsync.EpDate); break; } } } } } } else { // Actually we can't do this, because the user may have other non Anime series and Movies /* // series doesn't exist locally at all, so let's completely remove it from Trakt foreach (TraktV2WatchedSeason wtchSeason in wtch.seasons) { foreach (TraktV2WatchedEpisode wtchEp in wtchSeason.episodes) { string msg = string.Format("SYNC ONLINE: Removing from Trakt History: Slug: {0} - S:{1} - EP:{2}", wtch.show.ids.slug, wtchSeason.number, wtchEp.number); logger.Trace(msg); SyncEpisodeToTrakt(TraktSyncType.HistoryRemove, wtch.show.ids.slug, wtchSeason.number, wtchEp.number, DateTime.Now, false); } }*/ } } #endregion // send the data to Trakt string json = string.Empty; string url = TraktURIs.SyncCollectionAdd; string retData = string.Empty; if (syncCollectionAdd.shows != null && syncCollectionAdd.shows.Count > 0) { json = JSONHelper.Serialize<TraktV2SyncCollectionEpisodesByNumber>(syncCollectionAdd); url = TraktURIs.SyncCollectionAdd; retData = string.Empty; SendData(url, json, "POST", BuildRequestHeaders(), ref retData); } if (syncCollectionRemove.shows != null && syncCollectionRemove.shows.Count > 0) { json = JSONHelper.Serialize<TraktV2SyncCollectionEpisodesByNumber>(syncCollectionRemove); url = TraktURIs.SyncCollectionRemove; retData = string.Empty; SendData(url, json, "POST", BuildRequestHeaders(), ref retData); } if (syncHistoryAdd.shows != null && syncHistoryAdd.shows.Count > 0) { json = JSONHelper.Serialize<TraktV2SyncWatchedEpisodesByNumber>(syncHistoryAdd); url = TraktURIs.SyncHistoryAdd; retData = string.Empty; SendData(url, json, "POST", BuildRequestHeaders(), ref retData); } if (syncHistoryRemove.shows != null && syncHistoryRemove.shows.Count > 0) { json = JSONHelper.Serialize<TraktV2SyncWatchedEpisodesByNumber>(syncHistoryRemove); url = TraktURIs.SyncHistoryRemove; retData = string.Empty; SendData(url, json, "POST", BuildRequestHeaders(), ref retData); } logger.Trace("Test"); } catch (Exception ex) { logger.ErrorException("Error in TraktTVHelper.SyncCollectionToTrakt: " + ex.ToString(), ex); } }
public static void SyncCollectionToTrakt_Series(AnimeSeries series) { try { // check that we have at least one user nominated for Trakt JMMUserRepository repUsers = new JMMUserRepository(); List<JMMUser> traktUsers = repUsers.GetTraktUsers(); if (traktUsers.Count == 0) return; AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); AniDB_Anime anime = repAnime.GetByAnimeID(series.AniDB_ID); if (anime == null) return; TraktSummaryContainer traktSummary = new TraktSummaryContainer(); traktSummary.Populate(series.AniDB_ID); if (traktSummary.CrossRefTraktV2 == null || traktSummary.CrossRefTraktV2.Count == 0) return; // now get the full users collection from Trakt List<TraktV2ShowCollectedResult> collected = new List<TraktV2ShowCollectedResult>(); List<TraktV2ShowWatchedResult> watched = new List<TraktV2ShowWatchedResult>(); if (!GetTraktCollectionInfo(ref collected, ref watched)) return; foreach (AnimeEpisode ep in series.GetAnimeEpisodes()) { if (ep.EpisodeTypeEnum == enEpisodeType.Episode || ep.EpisodeTypeEnum == enEpisodeType.Special) { ReconSyncTraktEpisode(series, ep, traktSummary, traktUsers, collected, watched, true); } } } catch (Exception ex) { logger.ErrorException("Error in TraktTVHelper.SyncCollectionToTrakt_Series: " + ex.ToString(), ex); } }
public override void ProcessCommand() { logger.Info("Processing CommandRequest_TraktSearchAnime: {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 { CrossRef_AniDB_TraktResult crossRef = XMLService.Get_CrossRef_AniDB_Trakt(AnimeID); if (crossRef != null) { TraktTVShow showInfo = TraktTVHelper.GetShowInfo(crossRef.TraktID); if (showInfo != null) { logger.Trace("Found trakt match on web cache for {0} - id = {1}", AnimeID, showInfo.title); TraktTVHelper.LinkAniDBTrakt(AnimeID, crossRef.TraktID, crossRef.TraktSeasonNumber, true); return; } } } catch (Exception ex) { logger.ErrorException(ex.ToString(), ex); } } // lets try to see locally if we have a tvDB link for this anime // Trakt allows the use of TvDB ID's or their own Trakt ID's CrossRef_AniDB_TvDBV2Repository repCrossRefTvDB = new CrossRef_AniDB_TvDBV2Repository(); List<CrossRef_AniDB_TvDBV2> xrefTvDBs = repCrossRefTvDB.GetByAnimeID(session, AnimeID); if (xrefTvDBs != null && xrefTvDBs.Count == 1) //TODO this is temporary code, until trakt also allows multiple links { TraktTVShow showInfo = TraktTVHelper.GetShowInfo(xrefTvDBs[0].TvDBID); if (showInfo != null) { // make sure the season specified by TvDB also exists on Trakt Trakt_ShowRepository repShow = new Trakt_ShowRepository(); Trakt_Show traktShow = repShow.GetByTraktID(session, showInfo.TraktID); if (traktShow != null) { Trakt_SeasonRepository repSeasons = new Trakt_SeasonRepository(); Trakt_Season traktSeason = repSeasons.GetByShowIDAndSeason(session, traktShow.Trakt_ShowID, xrefTvDBs[0].TvDBSeasonNumber); if (traktSeason != null) { logger.Trace("Found trakt match using TvDBID locally {0} - id = {1}", AnimeID, showInfo.title); TraktTVHelper.LinkAniDBTrakt(AnimeID, showInfo.TraktID, traktSeason.Season, true); return; } } } } // if not lets try the tvdb web cache based on the same reasoning if (ServerSettings.WebCache_TvDB_Get) { List<JMMServer.Providers.Azure.CrossRef_AniDB_TvDB> cacheResults = JMMServer.Providers.Azure.AzureWebAPI.Get_CrossRefAniDBTvDB(AnimeID); if (cacheResults != null && cacheResults.Count > 0) { TraktTVShow showInfo = TraktTVHelper.GetShowInfo(cacheResults[0].TvDBID); if (showInfo != null) { // make sure the season specified by TvDB also exists on Trakt Trakt_ShowRepository repShow = new Trakt_ShowRepository(); Trakt_Show traktShow = repShow.GetByTraktID(session, showInfo.TraktID); if (traktShow != null) { Trakt_SeasonRepository repSeasons = new Trakt_SeasonRepository(); Trakt_Season traktSeason = repSeasons.GetByShowIDAndSeason(session, traktShow.Trakt_ShowID, cacheResults[0].TvDBSeasonNumber); if (traktSeason != null) { logger.Trace("Found trakt match on web cache by using TvDBID {0} - id = {1}", AnimeID, showInfo.title); TraktTVHelper.LinkAniDBTrakt(AnimeID, showInfo.TraktID, traktSeason.Season, true); return; } } } } } // finally lets try searching Trakt directly 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<TraktTVShow> results = TraktTVHelper.SearchShow(searchCriteria); logger.Trace("Found {0} trakt results for {1} ", 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 = TraktTVHelper.SearchShow(searchCriteria); logger.Trace("Found {0} trakt 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; } }
private void ProcessFile_AniDB(VideoLocal vidLocal) { logger.Trace("Checking for AniDB_File record for: {0} --- {1}", vidLocal.Hash, vidLocal.FilePath); // check if we already have this AniDB_File info in the database AniDB_FileRepository repAniFile = new AniDB_FileRepository(); AniDB_EpisodeRepository repAniEps = new AniDB_EpisodeRepository(); AniDB_AnimeRepository repAniAnime = new AniDB_AnimeRepository(); AnimeSeriesRepository repSeries = new AnimeSeriesRepository(); VideoLocalRepository repVidLocals = new VideoLocalRepository(); AnimeEpisodeRepository repEps = new AnimeEpisodeRepository(); CrossRef_File_EpisodeRepository repXrefFE = new CrossRef_File_EpisodeRepository(); AniDB_File aniFile = null; if (!ForceAniDB) { aniFile = repAniFile.GetByHashAndFileSize(vidLocal.Hash, vlocal.FileSize); if (aniFile == null) logger.Trace("AniDB_File record not found"); } int animeID = 0; if (aniFile == null) { // get info from AniDB logger.Debug("Getting AniDB_File record from AniDB...."); Raw_AniDB_File fileInfo = JMMService.AnidbProcessor.GetFileInfo(vidLocal); if (fileInfo != null) { // check if we already have a record aniFile = repAniFile.GetByHashAndFileSize(vidLocal.Hash, vlocal.FileSize); if (aniFile == null) aniFile = new AniDB_File(); aniFile.Populate(fileInfo); //overwrite with local file name string localFileName = Path.GetFileName(vidLocal.FilePath); aniFile.FileName = localFileName; repAniFile.Save(aniFile, false); aniFile.CreateLanguages(); aniFile.CreateCrossEpisodes(localFileName); if (!string.IsNullOrEmpty(fileInfo.OtherEpisodesRAW)) { string[] epIDs = fileInfo.OtherEpisodesRAW.Split(','); foreach (string epid in epIDs) { int id = 0; if (int.TryParse(epid, out id)) { CommandRequest_GetEpisode cmdEp = new CommandRequest_GetEpisode(id); cmdEp.Save(); } } } animeID = aniFile.AnimeID; } } 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 List<CrossRef_File_Episode> crossRefs = repXrefFE.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.WebCache_XRefFileEpisode_Get) { crossRefs = XMLService.Get_CrossRef_File_Episode(vidLocal); if (crossRefs == null || crossRefs.Count == 0) { logger.Debug("Cannot find AniDB_File record or get cross ref from web cache record so exiting: {0}", vidLocal.ED2KHash); return; } else { foreach (CrossRef_File_Episode xref in crossRefs) { // in this case we need to save the cross refs manually as AniDB did not provide them repXrefFE.Save(xref); } } } else { logger.Debug("Cannot get AniDB_File record so exiting: {0}", 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 = repAniEps.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: {0}", vidLocal.ED2KHash); missingEpisodes = true; } else { foreach (CrossRef_File_Episode xref in aniFile.EpisodeCrossRefs) { AniDB_Episode ep = repAniEps.GetByEpisodeID(xref.EpisodeID); if (ep == null) missingEpisodes = true; animeID = xref.AnimeID; } } } // get from DB AniDB_Anime anime = repAniAnime.GetByAnimeID(animeID); bool animeRecentlyUpdated = false; if (anime != null) { TimeSpan ts = DateTime.Now - anime.DateTimeUpdated; if (ts.TotalHours < 4) animeRecentlyUpdated = 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...."); // try using the cache first using (var session = JMMService.SessionFactory.OpenSession()) { anime = JMMService.AnidbProcessor.GetAnimeInfoHTTPFromCache(session, animeID, ServerSettings.AutoGroupSeries); } // if not in cache try from AniDB if (anime == null) anime = JMMService.AnidbProcessor.GetAnimeInfoHTTP(animeID, true, ServerSettings.AutoGroupSeries); } // create the group/series/episode records if needed AnimeSeries ser = null; if (anime != null) { logger.Debug("Creating groups, series and episodes...."); // check if there is an AnimeSeries Record associated with this AnimeID ser = repSeries.GetByAnimeID(animeID); if (ser == null) { // create a new AnimeSeries record ser = anime.CreateAnimeSeriesAndGroup(); } ser.CreateAnimeEpisodes(); // check if we have any group status data for this associated anime // if not we will download it now AniDB_GroupStatusRepository repStatus = new AniDB_GroupStatusRepository(); if (repStatus.GetByAnimeID(anime.AnimeID).Count == 0) { CommandRequest_GetReleaseGroupStatus cmdStatus = new CommandRequest_GetReleaseGroupStatus(anime.AnimeID, false); cmdStatus.Save(); } // update stats ser.EpisodeAddedDate = DateTime.Now; repSeries.Save(ser); AnimeGroupRepository repGroups = new AnimeGroupRepository(); foreach (AnimeGroup grp in ser.AllGroupsAbove) { grp.EpisodeAddedDate = DateTime.Now; repGroups.Save(grp); } } vidLocal.RenameIfRequired(); vidLocal.MoveFileIfRequired(); // update stats for groups and series if (ser != null) { // update all the groups above this series in the heirarchy ser.UpdateStats(true, true, true); StatsCache.Instance.UpdateUsingSeries(ser.AnimeSeriesID); } // Add this file to the users list if (ServerSettings.AniDB_MyList_AddFiles) { CommandRequest_AddFileToMyList cmd = new CommandRequest_AddFileToMyList(vidLocal.ED2KHash); cmd.Save(); } // lets also try adding to the users trakt collecion by sync'ing the series if (ser != null) { CommandRequest_TraktSyncCollectionSeries cmdTrakt = new CommandRequest_TraktSyncCollectionSeries(ser.AnimeSeriesID, ser.GetAnime().MainTitle); cmdTrakt.Save(); } // sync the series on MAL if (ser != null) { CommandRequest_MALUpdatedWatchedStatus cmdMAL = new CommandRequest_MALUpdatedWatchedStatus(ser.AniDB_ID); cmdMAL.Save(); } }
void workerMyAnime2_DoWork(object sender, DoWorkEventArgs e) { MA2Progress ma2Progress = new MA2Progress(); ma2Progress.CurrentFile = 0; ma2Progress.ErrorMessage = ""; ma2Progress.MigratedFiles = 0; ma2Progress.TotalFiles = 0; try { string databasePath = e.Argument as string; string connString = string.Format(@"data source={0};useutf16encoding=True", databasePath); SQLiteConnection myConn = new SQLiteConnection(connString); myConn.Open(); // get a list of unlinked files VideoLocalRepository repVids = new VideoLocalRepository(); AniDB_EpisodeRepository repAniEps = new AniDB_EpisodeRepository(); AniDB_AnimeRepository repAniAnime = new AniDB_AnimeRepository(); AnimeSeriesRepository repSeries = new AnimeSeriesRepository(); AnimeEpisodeRepository repEps = new AnimeEpisodeRepository(); List<VideoLocal> vids = repVids.GetVideosWithoutEpisode(); ma2Progress.TotalFiles = vids.Count; foreach (VideoLocal vid in vids) { ma2Progress.CurrentFile = ma2Progress.CurrentFile + 1; workerMyAnime2.ReportProgress(0, ma2Progress); // search for this file in the XrossRef table in MA2 string sql = string.Format("SELECT AniDB_EpisodeID from CrossRef_Episode_FileHash WHERE Hash = '{0}' AND FileSize = {1}", vid.ED2KHash, vid.FileSize); SQLiteCommand sqCommand = new SQLiteCommand(sql); sqCommand.Connection = myConn; SQLiteDataReader myReader = sqCommand.ExecuteReader(); while (myReader.Read()) { int episodeID = 0; if (!int.TryParse(myReader.GetValue(0).ToString(), out episodeID)) continue; if (episodeID <= 0) continue; sql = string.Format("SELECT AnimeID from AniDB_Episode WHERE EpisodeID = {0}", episodeID); sqCommand = new SQLiteCommand(sql); sqCommand.Connection = myConn; SQLiteDataReader myReader2 = sqCommand.ExecuteReader(); while (myReader2.Read()) { int animeID = myReader2.GetInt32(0); // so now we have all the needed details we can link the file to the episode // as long as wehave the details in JMM AniDB_Anime anime = null; AniDB_Episode ep = repAniEps.GetByEpisodeID(episodeID); if (ep == null) { logger.Debug("Getting Anime record from AniDB...."); anime = JMMService.AnidbProcessor.GetAnimeInfoHTTP(animeID, true, ServerSettings.AutoGroupSeries); } else anime = repAniAnime.GetByAnimeID(animeID); // create the group/series/episode records if needed AnimeSeries ser = null; if (anime == null) continue; logger.Debug("Creating groups, series and episodes...."); // check if there is an AnimeSeries Record associated with this AnimeID ser = repSeries.GetByAnimeID(animeID); if (ser == null) { // create a new AnimeSeries record ser = anime.CreateAnimeSeriesAndGroup(); } ser.CreateAnimeEpisodes(); // check if we have any group status data for this associated anime // if not we will download it now AniDB_GroupStatusRepository repStatus = new AniDB_GroupStatusRepository(); if (repStatus.GetByAnimeID(anime.AnimeID).Count == 0) { CommandRequest_GetReleaseGroupStatus cmdStatus = new CommandRequest_GetReleaseGroupStatus(anime.AnimeID, false); cmdStatus.Save(); } // update stats ser.EpisodeAddedDate = DateTime.Now; repSeries.Save(ser); AnimeGroupRepository repGroups = new AnimeGroupRepository(); foreach (AnimeGroup grp in ser.AllGroupsAbove) { grp.EpisodeAddedDate = DateTime.Now; repGroups.Save(grp); } AnimeEpisode epAnime = repEps.GetByAniDBEpisodeID(episodeID); if (epAnime == null) continue; CrossRef_File_EpisodeRepository repXRefs = new CrossRef_File_EpisodeRepository(); CrossRef_File_Episode xref = new CrossRef_File_Episode(); try { xref.PopulateManually(vid, epAnime); } catch (Exception ex) { string msg = string.Format("Error populating XREF: {0} - {1}", vid.ToStringDetailed(), ex.ToString()); throw; } repXRefs.Save(xref); vid.RenameIfRequired(); vid.MoveFileIfRequired(); // update stats for groups and series if (ser != null) { // update all the groups above this series in the heirarchy ser.UpdateStats(true, true, true); StatsCache.Instance.UpdateUsingSeries(ser.AnimeSeriesID); } // Add this file to the users list if (ServerSettings.AniDB_MyList_AddFiles) { CommandRequest_AddFileToMyList cmd = new CommandRequest_AddFileToMyList(vid.ED2KHash); cmd.Save(); } ma2Progress.MigratedFiles = ma2Progress.MigratedFiles + 1; workerMyAnime2.ReportProgress(0, ma2Progress); } myReader2.Close(); //Console.WriteLine(myReader.GetString(0)); } myReader.Close(); } myConn.Close(); ma2Progress.CurrentFile = ma2Progress.CurrentFile + 1; workerMyAnime2.ReportProgress(0, ma2Progress); } catch (Exception ex) { logger.ErrorException(ex.ToString(), ex); ma2Progress.ErrorMessage = ex.Message; workerMyAnime2.ReportProgress(0, ma2Progress); } }
public System.IO.Stream GetImage(string ImageType, string ImageID) { AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); TvDB_ImagePosterRepository repPosters = new TvDB_ImagePosterRepository(); TvDB_EpisodeRepository repEpisodes = new TvDB_EpisodeRepository(); TvDB_ImageFanartRepository repFanart = new TvDB_ImageFanartRepository(); TvDB_ImageWideBannerRepository repWideBanners = new TvDB_ImageWideBannerRepository(); MovieDB_PosterRepository repMoviePosters = new MovieDB_PosterRepository(); MovieDB_FanartRepository repMovieFanart = new MovieDB_FanartRepository(); Trakt_ImageFanartRepository repTraktFanart = new Trakt_ImageFanartRepository(); Trakt_ImagePosterRepository repTraktPosters = new Trakt_ImagePosterRepository(); Trakt_EpisodeRepository repTraktEpisodes = new Trakt_EpisodeRepository(); Trakt_FriendRepository repTraktFriends = new Trakt_FriendRepository(); JMMImageType imageType = (JMMImageType)int.Parse(ImageType); switch (imageType) { case JMMImageType.AniDB_Cover: AniDB_Anime anime = repAnime.GetByAnimeID(int.Parse(ImageID)); if (anime == null) return null; if (File.Exists(anime.PosterPath)) { FileStream fs = File.OpenRead(anime.PosterPath); WebOperationContext.Current.OutgoingResponse.ContentType = "image/jpeg"; return fs; } else { logger.Trace("Could not find AniDB_Cover image: {0}", anime.PosterPath); return null; } case JMMImageType.AniDB_Character: AniDB_CharacterRepository repChar = new AniDB_CharacterRepository(); AniDB_Character chr = repChar.GetByID(int.Parse(ImageID)); if (chr == null) return null; if (File.Exists(chr.PosterPath)) { FileStream fs = File.OpenRead(chr.PosterPath); WebOperationContext.Current.OutgoingResponse.ContentType = "image/jpeg"; return fs; } else { logger.Trace("Could not find AniDB_Character image: {0}", chr.PosterPath); return null; } case JMMImageType.AniDB_Creator: AniDB_SeiyuuRepository repCreator = new AniDB_SeiyuuRepository(); AniDB_Seiyuu creator = repCreator.GetByID(int.Parse(ImageID)); if (creator == null) return null; if (File.Exists(creator.PosterPath)) { FileStream fs = File.OpenRead(creator.PosterPath); WebOperationContext.Current.OutgoingResponse.ContentType = "image/jpeg"; return fs; } else { logger.Trace("Could not find AniDB_Creator image: {0}", creator.PosterPath); return null; } case JMMImageType.TvDB_Cover: TvDB_ImagePoster poster = repPosters.GetByID(int.Parse(ImageID)); if (poster == null) return null; if (File.Exists(poster.FullImagePath)) { FileStream fs = File.OpenRead(poster.FullImagePath); WebOperationContext.Current.OutgoingResponse.ContentType = "image/jpeg"; return fs; } else { logger.Trace("Could not find TvDB_Cover image: {0}", poster.FullImagePath); return null; } case JMMImageType.TvDB_Banner: TvDB_ImageWideBanner wideBanner = repWideBanners.GetByID(int.Parse(ImageID)); if (wideBanner == null) return null; if (File.Exists(wideBanner.FullImagePath)) { FileStream fs = File.OpenRead(wideBanner.FullImagePath); WebOperationContext.Current.OutgoingResponse.ContentType = "image/jpeg"; return fs; } else { logger.Trace("Could not find TvDB_Banner image: {0}", wideBanner.FullImagePath); return null; } case JMMImageType.TvDB_Episode: TvDB_Episode ep = repEpisodes.GetByID(int.Parse(ImageID)); if (ep == null) return null; if (File.Exists(ep.FullImagePath)) { FileStream fs = File.OpenRead(ep.FullImagePath); WebOperationContext.Current.OutgoingResponse.ContentType = "image/jpeg"; return fs; } else { logger.Trace("Could not find TvDB_Episode image: {0}", ep.FullImagePath); return null; } case JMMImageType.TvDB_FanArt: TvDB_ImageFanart fanart = repFanart.GetByID(int.Parse(ImageID)); if (fanart == null) return null; if (File.Exists(fanart.FullImagePath)) { FileStream fs = File.OpenRead(fanart.FullImagePath); WebOperationContext.Current.OutgoingResponse.ContentType = "image/jpeg"; return fs; } else { logger.Trace("Could not find TvDB_FanArt image: {0}", fanart.FullImagePath); return null; } case JMMImageType.MovieDB_Poster: MovieDB_Poster mPoster = repMoviePosters.GetByID(int.Parse(ImageID)); if (mPoster == null) return null; // now find only the original size mPoster = repMoviePosters.GetByOnlineID(mPoster.ImageID, Constants.MovieDBImageSize.Original); if (mPoster == null) return null; if (File.Exists(mPoster.FullImagePath)) { FileStream fs = File.OpenRead(mPoster.FullImagePath); WebOperationContext.Current.OutgoingResponse.ContentType = "image/jpeg"; return fs; } else { logger.Trace("Could not find MovieDB_Poster image: {0}", mPoster.FullImagePath); return null; } case JMMImageType.MovieDB_FanArt: MovieDB_Fanart mFanart = repMovieFanart.GetByID(int.Parse(ImageID)); if (mFanart == null) return null; mFanart = repMovieFanart.GetByOnlineID(mFanart.ImageID, Constants.MovieDBImageSize.Original); if (mFanart == null) return null; if (File.Exists(mFanart.FullImagePath)) { FileStream fs = File.OpenRead(mFanart.FullImagePath); WebOperationContext.Current.OutgoingResponse.ContentType = "image/jpeg"; return fs; } else { logger.Trace("Could not find MovieDB_FanArt image: {0}", mFanart.FullImagePath); return null; } case JMMImageType.Trakt_Fanart: Trakt_ImageFanart tFanart = repTraktFanart.GetByID(int.Parse(ImageID)); if (tFanart == null) return null; if (File.Exists(tFanart.FullImagePath)) { FileStream fs = File.OpenRead(tFanart.FullImagePath); WebOperationContext.Current.OutgoingResponse.ContentType = "image/jpeg"; return fs; } else { logger.Trace("Could not find Trakt_Fanart image: {0}", tFanart.FullImagePath); return null; } case JMMImageType.Trakt_Friend: Trakt_Friend tFriend = repTraktFriends.GetByID(int.Parse(ImageID)); if (tFriend == null) return null; if (File.Exists(tFriend.FullImagePath)) { FileStream fs = File.OpenRead(tFriend.FullImagePath); WebOperationContext.Current.OutgoingResponse.ContentType = "image/jpeg"; return fs; } else { logger.Trace("Could not find Trakt_Friend image: {0}", tFriend.FullImagePath); return null; } case JMMImageType.Trakt_ActivityScrobble: case JMMImageType.Trakt_ShoutUser: Trakt_Friend tFriendScrobble = repTraktFriends.GetByID(int.Parse(ImageID)); if (tFriendScrobble == null) return null; if (File.Exists(tFriendScrobble.FullImagePath)) { FileStream fs = File.OpenRead(tFriendScrobble.FullImagePath); WebOperationContext.Current.OutgoingResponse.ContentType = "image/jpeg"; return fs; } else { logger.Trace("Could not find Trakt_ActivityScrobble image: {0}", tFriendScrobble.FullImagePath); return null; } case JMMImageType.Trakt_Poster: Trakt_ImagePoster tPoster = repTraktPosters.GetByID(int.Parse(ImageID)); if (tPoster == null) return null; if (File.Exists(tPoster.FullImagePath)) { FileStream fs = File.OpenRead(tPoster.FullImagePath); WebOperationContext.Current.OutgoingResponse.ContentType = "image/jpeg"; return fs; } else { logger.Trace("Could not find Trakt_Poster image: {0}", tPoster.FullImagePath); return null; } case JMMImageType.Trakt_Episode: case JMMImageType.Trakt_WatchedEpisode: Trakt_Episode tEpisode = repTraktEpisodes.GetByID(int.Parse(ImageID)); if (tEpisode == null) return null; if (File.Exists(tEpisode.FullImagePath)) { FileStream fs = File.OpenRead(tEpisode.FullImagePath); WebOperationContext.Current.OutgoingResponse.ContentType = "image/jpeg"; return fs; } else { logger.Trace("Could not find Trakt_Episode image: {0}", tEpisode.FullImagePath); return null; } default: return null; } }
private void SendToAzureXML() { DateTime dt = DateTime.Now.AddYears(-2); AniDB_AnimeRepository rep = new AniDB_AnimeRepository(); List<AniDB_Anime> allAnime = rep.GetAll(); int sentAnime = 0; foreach (AniDB_Anime anime in rep.GetAll()) { if (!anime.EndDate.HasValue) continue; if (anime.EndDate.Value > dt) continue; sentAnime++; CommandRequest_Azure_SendAnimeXML cmd = new CommandRequest_Azure_SendAnimeXML(anime.AnimeID); cmd.Save(); } logger.Info(string.Format("Sent Anime XML to Cache: {0} out of {1}", sentAnime, allAnime.Count)); }
void btnUploadAzureCache_Click(object sender, RoutedEventArgs e) { AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); List<AniDB_Anime> allAnime = repAnime.GetAll(); int cnt = 0; foreach (AniDB_Anime anime in allAnime) { cnt++; logger.Info(string.Format("Uploading anime {0} of {1} - {2}", cnt, allAnime.Count, anime.MainTitle)); try { CommandRequest_Azure_SendAnimeFull cmdAzure = new CommandRequest_Azure_SendAnimeFull(anime.AnimeID); cmdAzure.Save(); } catch { } } }
private void GenerateAzureList() { // get a lst of anime's that we already have AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); List<AniDB_Anime> allAnime = repAnime.GetAll(); Dictionary<int, int> localAnimeIDs = new Dictionary<int, int>(); foreach (AniDB_Anime anime in allAnime) { localAnimeIDs[anime.AnimeID] = anime.AnimeID; } // loop through the list of valid anime id's and add the ones we don't have yet Dictionary<int, int> validAnimeIDs = new Dictionary<int, int>(); string line; System.IO.StreamReader file = new System.IO.StreamReader(@"e:\animetitles.txt"); while ((line = file.ReadLine()) != null) { string[] titlesArray = line.Split('|'); try { int aid = int.Parse(titlesArray[0]); if (!localAnimeIDs.ContainsKey(aid)) validAnimeIDs[aid] = aid; } catch { } } file.Close(); string aids = ""; var shuffledList = validAnimeIDs.Values.OrderBy(a => Guid.NewGuid()); int i = 0; foreach (int animeID in shuffledList) { i++; if (!string.IsNullOrEmpty(aids)) aids += ","; aids += animeID; if (i == 250) { logger.Info(aids); aids = ""; i = 0; } } logger.Info(aids); }
public override void ProcessCommand() { logger.Info("Processing CommandRequest_GetUpdated"); try { List<int> animeIDsToUpdate = new List<int>(); ScheduledUpdateRepository repSched = new ScheduledUpdateRepository(); AnimeSeriesRepository repSeries = new AnimeSeriesRepository(); AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); // check the automated update table to see when the last time we ran this command ScheduledUpdate sched = repSched.GetByUpdateType((int)ScheduledUpdateType.AniDBUpdates); if (sched != null) { int freqHours = Utils.GetScheduledHours(ServerSettings.AniDB_Anime_UpdateFrequency); // if we have run this in the last 12 hours and are not forcing it, then exit TimeSpan tsLastRun = DateTime.Now - sched.LastUpdate; if (tsLastRun.TotalHours < freqHours) { if (!ForceRefresh) return; } } long webUpdateTime = 0; long webUpdateTimeNew = 0; if (sched == null) { // if this is the first time, lets ask for last 3 days DateTime localTime = DateTime.Now.AddDays(-3); DateTime utcTime = localTime.ToUniversalTime(); webUpdateTime = long.Parse(Utils.AniDBDate(utcTime)); webUpdateTimeNew = long.Parse(Utils.AniDBDate(DateTime.Now.ToUniversalTime())); sched = new ScheduledUpdate(); sched.UpdateType = (int)ScheduledUpdateType.AniDBUpdates; } else { logger.Trace("Last anidb info update was : {0}", sched.UpdateDetails); webUpdateTime = long.Parse(sched.UpdateDetails); webUpdateTimeNew = long.Parse(Utils.AniDBDate(DateTime.Now.ToUniversalTime())); DateTime timeNow = DateTime.Now.ToUniversalTime(); logger.Info(string.Format("{0} since last UPDATED command", Utils.FormatSecondsToDisplayTime(int.Parse((webUpdateTimeNew - webUpdateTime).ToString())))); } // get a list of updates from AniDB // startTime will contain the date/time from which the updates apply to JMMService.AnidbProcessor.GetUpdated(ref animeIDsToUpdate, ref webUpdateTime); // now save the update time from AniDB // we will use this next time as a starting point when querying the web cache sched.LastUpdate = DateTime.Now; sched.UpdateDetails = webUpdateTimeNew.ToString(); repSched.Save(sched); if (animeIDsToUpdate.Count == 0) { logger.Info("No anime to be updated"); return; } int countAnime = 0; int countSeries = 0; foreach (int animeID in animeIDsToUpdate) { // update the anime from HTTP AniDB_Anime anime = repAnime.GetByAnimeID(animeID); if (anime == null) { logger.Trace("No local record found for Anime ID: {0}, so skipping...", animeID); continue; } logger.Info("Updating CommandRequest_GetUpdated: {0} ", animeID); // but only if it hasn't been recently updated TimeSpan ts = DateTime.Now - anime.DateTimeUpdated; if (ts.TotalHours > 4) { CommandRequest_GetAnimeHTTP cmdAnime = new CommandRequest_GetAnimeHTTP(animeID, true, false); cmdAnime.Save(); countAnime++; } // update the group status // this will allow us to determine which anime has missing episodes // so we wonly get by an amime where we also have an associated series AnimeSeries ser = repSeries.GetByAnimeID(animeID); if (ser != null) { CommandRequest_GetReleaseGroupStatus cmdStatus = new CommandRequest_GetReleaseGroupStatus(animeID, true); cmdStatus.Save(); countSeries++; } } logger.Info("Updating {0} anime records, and {1} group status records", countAnime, countSeries); } catch (Exception ex) { logger.Error("Error processing CommandRequest_GetUpdated: {0}", ex.ToString()); return; } }
public override void ProcessCommand() { logger.Info("Processing CommandRequest_GetReleaseGroupStatus: {0}", AnimeID); try { // only get group status if we have an associated series AnimeSeriesRepository repSeries = new AnimeSeriesRepository(); AnimeSeries series = repSeries.GetByAnimeID(AnimeID); if (series == null) return; AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); AniDB_Anime anime = repAnime.GetByAnimeID(AnimeID); if (anime == null) return; // don't get group status if the anime has already ended more than 50 days ago bool skip = false; if (!ForceRefresh) { if (anime.EndDate.HasValue) { if (anime.EndDate.Value < DateTime.Now) { TimeSpan ts = DateTime.Now - anime.EndDate.Value; if (ts.TotalDays > 50) { // don't skip if we have never downloaded this info before AniDB_GroupStatusRepository repGrpStatus = new AniDB_GroupStatusRepository(); List<AniDB_GroupStatus> grpStatuses = repGrpStatus.GetByAnimeID(AnimeID); if (grpStatuses != null && grpStatuses.Count > 0) { skip = true; } } } } } if (skip) { logger.Info("Skipping group status command because anime has already ended: {0}", anime.ToString()); return; } GroupStatusCollection grpCol = JMMService.AnidbProcessor.GetReleaseGroupStatusUDP(AnimeID); if (ServerSettings.AniDB_DownloadReleaseGroups) { // save in bulk to improve performance using (var session = JMMService.SessionFactory.OpenSession()) { using (var transaction = session.BeginTransaction()) { foreach (Raw_AniDB_GroupStatus grpStatus in grpCol.Groups) { CommandRequest_GetReleaseGroup cmdRelgrp = new CommandRequest_GetReleaseGroup(grpStatus.GroupID, false); session.SaveOrUpdate(cmdRelgrp); } transaction.Commit(); } } } //} } catch (Exception ex) { logger.Error("Error processing CommandRequest_GetReleaseGroupStatus: {0} - {1}", AnimeID, ex.ToString()); return; } }
private static int? GetTraktEpisodeIdV2(AnimeEpisode ep, ref string traktID, ref int season, ref int epNumber) { AniDB_Episode aniep = ep.AniDB_Episode; if (aniep == null) return null; AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); AniDB_Anime anime = repAnime.GetByAnimeID(aniep.AnimeID); if (anime == null) return null; return GetTraktEpisodeIdV2(anime, aniep, ref traktID, ref season, ref epNumber); }
public override void ProcessCommand() { logger.Info("Processing CommandRequest_GetCalendar"); try { // we will always assume that an anime was downloaded via http first ScheduledUpdateRepository repSched = new ScheduledUpdateRepository(); AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); ScheduledUpdate sched = repSched.GetByUpdateType((int)ScheduledUpdateType.AniDBCalendar); if (sched == null) { sched = new ScheduledUpdate(); sched.UpdateType = (int)ScheduledUpdateType.AniDBCalendar; sched.UpdateDetails = ""; } else { int freqHours = Utils.GetScheduledHours(ServerSettings.AniDB_Calendar_UpdateFrequency); // if we have run this in the last 12 hours and are not forcing it, then exit TimeSpan tsLastRun = DateTime.Now - sched.LastUpdate; if (tsLastRun.TotalHours < freqHours) { if (!ForceRefresh) return; } } sched.LastUpdate = DateTime.Now; repSched.Save(sched); CalendarCollection colCalendars = JMMService.AnidbProcessor.GetCalendarUDP(); if (colCalendars == null || colCalendars.Calendars == null) { logger.Error("Could not get calendar from AniDB"); return; } foreach (AniDBAPI.Calendar cal in colCalendars.Calendars) { AniDB_Anime anime = repAnime.GetByAnimeID(cal.AnimeID); if (anime != null) { // don't update if the local data is less 2 days old TimeSpan ts = DateTime.Now - anime.DateTimeUpdated; if (ts.TotalDays >= 2) { CommandRequest_GetAnimeHTTP cmdAnime = new CommandRequest_GetAnimeHTTP(cal.AnimeID, true, false); cmdAnime.Save(); } else { // update the release date even if we don't update the anime record anime.AirDate = cal.ReleaseDate; repAnime.Save(anime); } } else { CommandRequest_GetAnimeHTTP cmdAnime = new CommandRequest_GetAnimeHTTP(cal.AnimeID, true, false); cmdAnime.Save(); } } } catch (Exception ex) { logger.ErrorException("Error processing CommandRequest_GetCalendar: " + ex.ToString(), ex); return; } }
public static string GetNewFileName(VideoLocal vid, string script) { string[] lines = script.Split(Environment.NewLine.ToCharArray()); string newFileName = string.Empty; AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); List<AniDB_Episode> episodes = new List<AniDB_Episode>(); AniDB_Anime anime = null; VideoInfo vi = vid.VideoInfo; if (vi == null) return string.Empty; // get all the data so we don't need to get multiple times AniDB_File aniFile = vid.GetAniDBFile(); if (aniFile == null) { List<AnimeEpisode> animeEps = vid.GetAnimeEpisodes(); if (animeEps.Count == 0) return string.Empty; episodes.Add(animeEps[0].AniDB_Episode); anime = repAnime.GetByAnimeID(episodes[0].AnimeID); if (anime == null) return string.Empty; } else { episodes = aniFile.Episodes; if (episodes.Count == 0) return string.Empty; anime = repAnime.GetByAnimeID(episodes[0].AnimeID); if (anime == null) return string.Empty; } foreach (string line in lines) { string thisLine = line.Trim(); if (thisLine.Length == 0) continue; // remove all comments from this line int comPos = thisLine.IndexOf("//"); if (comPos >= 0) { thisLine = thisLine.Substring(0, comPos); } // check if this line has no tests (applied to all files) if (thisLine.StartsWith(Constants.FileRenameReserved.Do, StringComparison.InvariantCultureIgnoreCase)) { string action = GetAction(thisLine); PerformActionOnFileName(ref newFileName, action, vid, aniFile, episodes, anime, vi); } else { try { if (EvaluateTest(thisLine, vid, aniFile, episodes, anime, vi)) { Debug.WriteLine(string.Format("Line passed: {0}", thisLine)); // if the line has passed the tests, then perform the action string action = GetAction(thisLine); // if the action is fail, we don't want to rename if (action.ToUpper().Trim().Equals(Constants.FileRenameReserved.Fail, StringComparison.InvariantCultureIgnoreCase)) return string.Empty; PerformActionOnFileName(ref newFileName, action, vid, aniFile, episodes, anime, vi); } else { Debug.WriteLine(string.Format("Line failed: {0}", thisLine)); } } catch (Exception ex) { throw; } } } if (string.IsNullOrEmpty(newFileName)) return string.Empty; // finally add back the extension return string.Format("{0}{1}", newFileName, Path.GetExtension(vid.FullServerPath)); }
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 ProcessCommand() { logger.Info("Processing CommandRequest_MALDownloadStatusFromMAL"); 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(); myanimelist mal = MALHelper.GetMALAnimeList(); if (mal == null) return; if (mal.anime == null) return; CrossRef_AniDB_MALRepository repCrossRef = new CrossRef_AniDB_MALRepository(); AniDB_EpisodeRepository repAniEps = new AniDB_EpisodeRepository(); AnimeEpisodeRepository repEp = new AnimeEpisodeRepository(); // find the anidb user JMMUserRepository repUsers = new JMMUserRepository(); List<JMMUser> aniDBUsers = repUsers.GetAniDBUsers(); if (aniDBUsers.Count == 0) return; JMMUser user = aniDBUsers[0]; foreach (myanimelistAnime malAnime in mal.anime) { // look up the anime CrossRef_AniDB_MAL xref = repCrossRef.GetByMALID(malAnime.series_animedb_id); if (xref == null) continue; if (malAnime.series_animedb_id == 8107 || malAnime.series_animedb_id == 10737) { Console.Write(""); } // check if this anime has any other links List<CrossRef_AniDB_MAL> allXrefs = repCrossRef.GetByAnimeID(xref.AnimeID); if (allXrefs.Count == 0) continue; // find the range of watched episodes that this applies to int startEpNumber = xref.StartEpisodeNumber; int endEpNumber = GetUpperEpisodeLimit(allXrefs, xref); List<AniDB_Episode> aniEps = repAniEps.GetByAnimeID(xref.AnimeID); foreach (AniDB_Episode aniep in aniEps) { if (aniep.EpisodeType != xref.StartEpisodeType) continue; AnimeEpisode ep = repEp.GetByAniDBEpisodeID(aniep.EpisodeID); if (ep == null) continue; int adjustedWatchedEps = malAnime.my_watched_episodes + xref.StartEpisodeNumber - 1; int epNum = aniep.EpisodeNumber; if (epNum < startEpNumber || epNum > endEpNumber) continue; AnimeEpisode_User usrRec = ep.GetUserRecord(user.JMMUserID); if (epNum <= adjustedWatchedEps) { // update if the user doesn't have a record (means not watched) // or it is currently un-watched bool update = false; if (usrRec == null) update = true; else { if (!usrRec.WatchedDate.HasValue) update = true; } if (update) ep.ToggleWatchedStatus(true, true, DateTime.Now, user.JMMUserID, false); } else { bool update = false; if (usrRec != null) { if (usrRec.WatchedDate.HasValue) update = true; } if (update) ep.ToggleWatchedStatus(false, true, DateTime.Now, user.JMMUserID, false); } } } } catch (Exception ex) { logger.Error("Error processing CommandRequest_MALDownloadStatusFromMAL: {0}", ex.ToString()); return; } }
public override void ProcessCommand() { logger.Info("Processing CommandRequest_TraktSearchAnime: {0}", AnimeID); try { using (var session = JMMService.SessionFactory.OpenSession()) { // first check if the user wants to use the web cache if (ServerSettings.WebCache_Trakt_Get) { try { List<Contract_Azure_CrossRef_AniDB_Trakt> contracts = new List<Contract_Azure_CrossRef_AniDB_Trakt>(); List<JMMServer.Providers.Azure.CrossRef_AniDB_Trakt> resultsCache = JMMServer.Providers.Azure.AzureWebAPI.Get_CrossRefAniDBTrakt(AnimeID); if (resultsCache != null && resultsCache.Count > 0) { foreach (JMMServer.Providers.Azure.CrossRef_AniDB_Trakt xref in resultsCache) { TraktV2ShowExtended showInfo = TraktTVHelper.GetShowInfoV2(xref.TraktID); if (showInfo != null) { logger.Trace("Found trakt match on web cache for {0} - id = {1}", AnimeID, showInfo.title); TraktTVHelper.LinkAniDBTrakt(AnimeID, (enEpisodeType)xref.AniDBStartEpisodeType, xref.AniDBStartEpisodeNumber, xref.TraktID, xref.TraktSeasonNumber, xref.TraktStartEpisodeNumber, true); return; } } } } catch (Exception ex) { logger.ErrorException(ex.ToString(), ex); } } // lets try to see locally if we have a tvDB link for this anime // Trakt allows the use of TvDB ID's or their own Trakt ID's CrossRef_AniDB_TvDBV2Repository repCrossRefTvDB = new CrossRef_AniDB_TvDBV2Repository(); List<CrossRef_AniDB_TvDBV2> xrefTvDBs = repCrossRefTvDB.GetByAnimeID(session, AnimeID); if (xrefTvDBs != null && xrefTvDBs.Count > 0) { foreach (CrossRef_AniDB_TvDBV2 tvXRef in xrefTvDBs) { // first search for this show by the TvDB ID List<TraktV2SearchTvDBIDShowResult> searchResults = TraktTVHelper.SearchShowByIDV2(TraktSearchIDType.tvdb, tvXRef.TvDBID.ToString()); if (searchResults != null && searchResults.Count > 0) { // since we are searching by ID, there will only be one 'show' result TraktV2Show resShow = null; foreach (TraktV2SearchTvDBIDShowResult res in searchResults) { if (res.ResultType == SearchIDType.Show) { resShow = res.show; break; } } if (resShow != null) { TraktV2ShowExtended showInfo = TraktTVHelper.GetShowInfoV2(resShow.ids.slug); if (showInfo != null && showInfo.ids != null) { // make sure the season specified by TvDB also exists on Trakt Trakt_ShowRepository repShow = new Trakt_ShowRepository(); Trakt_Show traktShow = repShow.GetByTraktSlug(session, showInfo.ids.slug); if (traktShow != null) { Trakt_SeasonRepository repSeasons = new Trakt_SeasonRepository(); Trakt_Season traktSeason = repSeasons.GetByShowIDAndSeason(session, traktShow.Trakt_ShowID, xrefTvDBs[0].TvDBSeasonNumber); if (traktSeason != null) { logger.Trace("Found trakt match using TvDBID locally {0} - id = {1}", AnimeID, showInfo.title); TraktTVHelper.LinkAniDBTrakt(AnimeID, (AniDBAPI.enEpisodeType)tvXRef.AniDBStartEpisodeType, tvXRef.AniDBStartEpisodeNumber, showInfo.ids.slug, tvXRef.TvDBSeasonNumber, tvXRef.TvDBStartEpisodeNumber, true); return; } } } } } } } // finally lets try searching Trakt directly 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<TraktV2SearchShowResult> results = TraktTVHelper.SearchShowV2(searchCriteria); logger.Trace("Found {0} trakt results for {1} ", 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 = TraktTVHelper.SearchShowV2(searchCriteria); logger.Trace("Found {0} trakt 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; } }