public static string LinkAniDBTvDB(int animeID, enEpisodeType aniEpType, int aniEpNumber, int tvDBID, int tvSeasonNumber, int tvEpNumber, bool excludeFromWebCache) { using (var session = JMMService.SessionFactory.OpenSession()) { CrossRef_AniDB_TvDBV2Repository repCrossRef = new CrossRef_AniDB_TvDBV2Repository(); List<CrossRef_AniDB_TvDBV2> xrefTemps = repCrossRef.GetByAnimeIDEpTypeEpNumber(session, animeID, (int)aniEpType, aniEpNumber); if (xrefTemps != null && xrefTemps.Count > 0) { foreach (CrossRef_AniDB_TvDBV2 xrefTemp in xrefTemps) { // delete the existing one if we are updating TvDBHelper.RemoveLinkAniDBTvDB(xrefTemp.AnimeID, (enEpisodeType)xrefTemp.AniDBStartEpisodeType, xrefTemp.AniDBStartEpisodeNumber, xrefTemp.TvDBID, xrefTemp.TvDBSeasonNumber, xrefTemp.TvDBStartEpisodeNumber); } } // check if we have this information locally // if not download it now TvDB_SeriesRepository repSeries = new TvDB_SeriesRepository(); TvDB_Series tvSeries = repSeries.GetByTvDBID(tvDBID); if (tvSeries == null) { // we download the series info here just so that we have the basic info in the // database before the queued task runs later tvSeries = GetSeriesInfoOnline(tvDBID); } // download and update series info, episode info and episode images // will also download fanart, posters and wide banners CommandRequest_TvDBUpdateSeriesAndEpisodes cmdSeriesEps = new CommandRequest_TvDBUpdateSeriesAndEpisodes(tvDBID, false); cmdSeriesEps.Save(); CrossRef_AniDB_TvDBV2 xref = repCrossRef.GetByTvDBID(session, tvDBID, tvSeasonNumber, tvEpNumber, animeID, (int)aniEpType, aniEpNumber); if (xref == null) xref = new CrossRef_AniDB_TvDBV2(); xref.AnimeID = animeID; xref.AniDBStartEpisodeType = (int)aniEpType; xref.AniDBStartEpisodeNumber = aniEpNumber; xref.TvDBID = tvDBID; xref.TvDBSeasonNumber = tvSeasonNumber; xref.TvDBStartEpisodeNumber = tvEpNumber; if (tvSeries != null) xref.TvDBTitle = tvSeries.SeriesName; if (excludeFromWebCache) xref.CrossRefSource = (int)CrossRefSource.WebCache; else xref.CrossRefSource = (int)CrossRefSource.User; repCrossRef.Save(xref); StatsCache.Instance.UpdateUsingAnime(animeID); logger.Trace("Changed tvdb association: {0}", animeID); if (!excludeFromWebCache) { CommandRequest_WebCacheSendXRefAniDBTvDB req = new CommandRequest_WebCacheSendXRefAniDBTvDB(xref.CrossRef_AniDB_TvDBV2ID); req.Save(); } if (ServerSettings.Trakt_IsEnabled && !string.IsNullOrEmpty(ServerSettings.Trakt_AuthToken)) { CrossRef_AniDB_TraktV2Repository repTraktXrefs = new CrossRef_AniDB_TraktV2Repository(); if (repTraktXrefs.GetByAnimeID(animeID).Count == 0) { // check for Trakt associations CommandRequest_TraktSearchAnime cmd2 = new CommandRequest_TraktSearchAnime(animeID, false); cmd2.Save(session); } } } return ""; }
public static void ScanForMatches() { AnimeSeriesRepository repSeries = new AnimeSeriesRepository(); List<AnimeSeries> allSeries = repSeries.GetAll(); CrossRef_AniDB_TraktV2Repository repCrossRef = new CrossRef_AniDB_TraktV2Repository(); List<CrossRef_AniDB_TraktV2> allCrossRefs = repCrossRef.GetAll(); List<int> alreadyLinked = new List<int>(); foreach (CrossRef_AniDB_TraktV2 xref in allCrossRefs) { alreadyLinked.Add(xref.AnimeID); } foreach (AnimeSeries ser in allSeries) { if (alreadyLinked.Contains(ser.AniDB_ID)) continue; AniDB_Anime anime = ser.GetAnime(); if (anime != null) logger.Trace("Found anime without Trakt association: " + anime.MainTitle); if (anime.IsTraktLinkDisabled) continue; CommandRequest_TraktSearchAnime cmd = new CommandRequest_TraktSearchAnime(ser.AniDB_ID, false); cmd.Save(); } }
public Contract_AnimeSeries_SaveResponse CreateSeriesFromAnime(int animeID, int? animeGroupID, int userID) { Contract_AnimeSeries_SaveResponse response = new Contract_AnimeSeries_SaveResponse(); response.AnimeSeries = null; response.ErrorMessage = ""; try { using (var session = JMMService.SessionFactory.OpenSession()) { AnimeGroupRepository repGroups = new AnimeGroupRepository(); if (animeGroupID.HasValue) { AnimeGroup grp = repGroups.GetByID(session, animeGroupID.Value); if (grp == null) { response.ErrorMessage = "Could not find the specified group"; return response; } } // make sure a series doesn't already exists for this anime AnimeSeriesRepository repSeries = new AnimeSeriesRepository(); AnimeSeries ser = repSeries.GetByAnimeID(session, animeID); if (ser != null) { response.ErrorMessage = "A series already exists for this anime"; return response; } // make sure the anime exists first AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository(); AniDB_Anime anime = repAnime.GetByAnimeID(session, animeID); if (anime == null) anime = JMMService.AnidbProcessor.GetAnimeInfoHTTP(session, animeID, false, false); if (anime == null) { response.ErrorMessage = "Could not get anime information from AniDB"; return response; } if (animeGroupID.HasValue) { ser = new AnimeSeries(); ser.Populate(anime); ser.AnimeGroupID = animeGroupID.Value; repSeries.Save(ser); } else { ser = anime.CreateAnimeSeriesAndGroup(session); } ser.CreateAnimeEpisodes(session); // 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(session); } ser.QueueUpdateStats(); // check for TvDB associations CommandRequest_TvDBSearchAnime cmd = new CommandRequest_TvDBSearchAnime(anime.AnimeID, false); cmd.Save(session); if (ServerSettings.Trakt_IsEnabled && !string.IsNullOrEmpty(ServerSettings.Trakt_AuthToken)) { // check for Trakt associations CommandRequest_TraktSearchAnime cmd2 = new CommandRequest_TraktSearchAnime(anime.AnimeID, false); cmd2.Save(session); } List<CrossRef_AniDB_TvDBV2> xrefs = ser.GetCrossRefTvDBV2(); List<CrossRef_AniDB_MAL> xrefMAL = ser.CrossRefMAL; List<TvDB_Series> sers = new List<TvDB_Series>(); foreach (CrossRef_AniDB_TvDBV2 xref in xrefs) sers.Add(xref.GetTvDBSeries()); CrossRef_AniDB_Other xrefMovie = ser.CrossRefMovieDB; MovieDB_Movie movie = null; if (xrefMovie != null) movie = xrefMovie.GetMovieDB_Movie(); response.AnimeSeries = ser.ToContract(anime, xrefs, xrefMovie, ser.GetUserRecord(userID), sers, xrefMAL, false, null, null, null, null,movie); return response; } } catch (Exception ex) { logger.ErrorException(ex.ToString(), ex); response.ErrorMessage = ex.Message; } return response; }
// List of Default priorities for commands // Pri 1 //------ // Reserved for commands user manually initiates from UI //------ // Pri 2 //------ // CommandRequest_GetAnimeHTTP //------ // Pri 3 //------ // CommandRequest_ProcessFile // CommandRequest_GetFile //------ // Pri 4 //------ // CommandRequest_GetUpdated // CommandRequest_ReadMediaInfo // CommandRequest_GetEpsode //------ // Pri 5 //------ // CommandRequest_GetReleaseGroupStatus //------ // Pri 6 //------ // CommandRequest_SyncMyList // CommandRequest_SyncMyVotes //------ // Pri 7 //------ // CommandRequest_GetCalendar //------ // Pri 8 //------ // CommandRequest_UpdateMyListFileStatus // CommandRequest_GetCharactersCreators // CommandRequest_TraktSyncCollection // CommandRequest_TvDBUpdateSeriesAndEpisodes // CommandRequest_TvDBDownloadImages // CommandRequest_TvDBSearchAnime // CommandRequest_MovieDBSearchAnime // CommandRequest_TraktSearchAnime // CommandRequest_MALSearchAnime //------ // Pri 9 //------ // CommandRequest_WebCacheSendFileHash // CommandRequest_GetReviews // CommandRequest_GetReleaseGroup // CommandRequest_WebCacheSendXRefFileEpisode // CommandRequest_WebCacheDeleteXRefFileEpisode // CommandRequest_AddFileToMyList // CommandRequest_DeleteFileFromMyList // CommandRequest_VoteAnime // CommandRequest_WebCacheDeleteXRefAniDBTvDB // CommandRequest_WebCacheDeleteXRefAniDBTvDBAll // CommandRequest_WebCacheSendXRefAniDBTvDB // CommandRequest_WebCacheSendXRefAniDBOther // CommandRequest_WebCacheDeleteXRefAniDBOther // CommandRequest_WebCacheDeleteXRefAniDBTrakt // CommandRequest_WebCacheSendXRefAniDBTrakt // CommandRequest_TraktUpdateInfoAndImages // CommandRequest_TraktSyncCollectionSeries // CommandRequest_TraktShowEpisodeUnseen // CommandRequest_DownloadImage // CommandRequest_TraktUpdateAllSeries // CommandRequest_MALUpdatedWatchedStatus // CommandRequest_MALUploadStatusToMAL // CommandRequest_MALDownloadStatusFromMAL // CommandRequest_WebCacheSendAniDB_File // CommandRequest_Azure_SendAnimeFull //------ // Pri 10 //------ // CommandRequest_UpdateMylistStats // CommandRequest_Azure_SendAnimeXML //------ // Pri 11 //------ // CommandRequest_Azure_SendAnimeTitle public static ICommandRequest GetCommand(CommandRequest crdb) { CommandRequestType crt = (CommandRequestType)crdb.CommandType; switch (crt) { case CommandRequestType.Trakt_SyncCollectionSeries: CommandRequest_TraktSyncCollectionSeries cr_CommandRequest_TraktSyncCollectionSeries = new CommandRequest_TraktSyncCollectionSeries(); cr_CommandRequest_TraktSyncCollectionSeries.LoadFromDBCommand(crdb); return((ICommandRequest)cr_CommandRequest_TraktSyncCollectionSeries); case CommandRequestType.AniDB_GetEpisodeUDP: CommandRequest_GetEpisode cr_CommandRequest_GetEpisode = new CommandRequest_GetEpisode(); cr_CommandRequest_GetEpisode.LoadFromDBCommand(crdb); return((ICommandRequest)cr_CommandRequest_GetEpisode); case CommandRequestType.Azure_SendAnimeTitle: CommandRequest_Azure_SendAnimeTitle cr_CommandRequest_Azure_SendAnimeTitle = new CommandRequest_Azure_SendAnimeTitle(); cr_CommandRequest_Azure_SendAnimeTitle.LoadFromDBCommand(crdb); return((ICommandRequest)cr_CommandRequest_Azure_SendAnimeTitle); case CommandRequestType.AniDB_GetTitles: CommandRequest_GetAniDBTitles cr_CommandRequest_GetAniDBTitles = new CommandRequest_GetAniDBTitles(); cr_CommandRequest_GetAniDBTitles.LoadFromDBCommand(crdb); return((ICommandRequest)cr_CommandRequest_GetAniDBTitles); case CommandRequestType.Azure_SendAnimeXML: CommandRequest_Azure_SendAnimeXML cr_CommandRequest_Azure_SendAnimeXML = new CommandRequest_Azure_SendAnimeXML(); cr_CommandRequest_Azure_SendAnimeXML.LoadFromDBCommand(crdb); return((ICommandRequest)cr_CommandRequest_Azure_SendAnimeXML); case CommandRequestType.Azure_SendAnimeFull: CommandRequest_Azure_SendAnimeFull cr_CommandRequest_Azure_SendAnimeFull = new CommandRequest_Azure_SendAnimeFull(); cr_CommandRequest_Azure_SendAnimeFull.LoadFromDBCommand(crdb); return((ICommandRequest)cr_CommandRequest_Azure_SendAnimeFull); case CommandRequestType.Azure_SendUserInfo: CommandRequest_Azure_SendUserInfo cr_CommandRequest_Azure_SendUserInfo = new CommandRequest_Azure_SendUserInfo(); cr_CommandRequest_Azure_SendUserInfo.LoadFromDBCommand(crdb); return((ICommandRequest)cr_CommandRequest_Azure_SendUserInfo); case CommandRequestType.AniDB_UpdateMylistStats: CommandRequest_UpdateMylistStats cr_AniDB_UpdateMylistStats = new CommandRequest_UpdateMylistStats(); cr_AniDB_UpdateMylistStats.LoadFromDBCommand(crdb); return((ICommandRequest)cr_AniDB_UpdateMylistStats); case CommandRequestType.MAL_DownloadWatchedStates: CommandRequest_MALDownloadStatusFromMAL cr_MAL_DownloadWatchedStates = new CommandRequest_MALDownloadStatusFromMAL(); cr_MAL_DownloadWatchedStates.LoadFromDBCommand(crdb); return((ICommandRequest)cr_MAL_DownloadWatchedStates); case CommandRequestType.MAL_UploadWatchedStates: CommandRequest_MALUploadStatusToMAL cr_MAL_UploadWatchedStates = new CommandRequest_MALUploadStatusToMAL(); cr_MAL_UploadWatchedStates.LoadFromDBCommand(crdb); return((ICommandRequest)cr_MAL_UploadWatchedStates); case CommandRequestType.MAL_UpdateStatus: CommandRequest_MALUpdatedWatchedStatus cr_MAL_UpdateStatus = new CommandRequest_MALUpdatedWatchedStatus(); cr_MAL_UpdateStatus.LoadFromDBCommand(crdb); return((ICommandRequest)cr_MAL_UpdateStatus); case CommandRequestType.MAL_SearchAnime: CommandRequest_MALSearchAnime cr_MAL_SearchAnime = new CommandRequest_MALSearchAnime(); cr_MAL_SearchAnime.LoadFromDBCommand(crdb); return((ICommandRequest)cr_MAL_SearchAnime); case CommandRequestType.WebCache_SendXRefAniDBMAL: CommandRequest_WebCacheSendXRefAniDBMAL cr_WebCacheSendXRefAniDBMAL = new CommandRequest_WebCacheSendXRefAniDBMAL(); cr_WebCacheSendXRefAniDBMAL.LoadFromDBCommand(crdb); return((ICommandRequest)cr_WebCacheSendXRefAniDBMAL); case CommandRequestType.WebCache_DeleteXRefAniDBMAL: CommandRequest_WebCacheDeleteXRefAniDBMAL cr_WebCacheDeleteXRefAniDBMAL = new CommandRequest_WebCacheDeleteXRefAniDBMAL(); cr_WebCacheDeleteXRefAniDBMAL.LoadFromDBCommand(crdb); return((ICommandRequest)cr_WebCacheDeleteXRefAniDBMAL); case CommandRequestType.AniDB_GetFileUDP: CommandRequest_GetFile cr_AniDB_GetFileUDP = new CommandRequest_GetFile(); cr_AniDB_GetFileUDP.LoadFromDBCommand(crdb); return((ICommandRequest)cr_AniDB_GetFileUDP); case CommandRequestType.ReadMediaInfo: CommandRequest_ReadMediaInfo cr_ReadMediaInfo = new CommandRequest_ReadMediaInfo(); cr_ReadMediaInfo.LoadFromDBCommand(crdb); return((ICommandRequest)cr_ReadMediaInfo); case CommandRequestType.Trakt_UpdateAllSeries: CommandRequest_TraktUpdateAllSeries cr_Trakt_UpdateAllSeries = new CommandRequest_TraktUpdateAllSeries(); cr_Trakt_UpdateAllSeries.LoadFromDBCommand(crdb); return((ICommandRequest)cr_Trakt_UpdateAllSeries); case CommandRequestType.Trakt_EpisodeCollection: CommandRequest_TraktCollectionEpisode cr_TraktCollectionEpisode = new CommandRequest_TraktCollectionEpisode(); cr_TraktCollectionEpisode.LoadFromDBCommand(crdb); return((ICommandRequest)cr_TraktCollectionEpisode); case CommandRequestType.Trakt_SyncCollection: CommandRequest_TraktSyncCollection cr_Trakt_SyncCollection = new CommandRequest_TraktSyncCollection(); cr_Trakt_SyncCollection.LoadFromDBCommand(crdb); return((ICommandRequest)cr_Trakt_SyncCollection); case CommandRequestType.Trakt_EpisodeHistory: CommandRequest_TraktHistoryEpisode cr_Trakt_EpisodeHistory = new CommandRequest_TraktHistoryEpisode(); cr_Trakt_EpisodeHistory.LoadFromDBCommand(crdb); return((ICommandRequest)cr_Trakt_EpisodeHistory); case CommandRequestType.Trakt_UpdateInfoImages: CommandRequest_TraktUpdateInfoAndImages cr_Trakt_UpdateInfoImages = new CommandRequest_TraktUpdateInfoAndImages(); cr_Trakt_UpdateInfoImages.LoadFromDBCommand(crdb); return((ICommandRequest)cr_Trakt_UpdateInfoImages); case CommandRequestType.WebCache_SendXRefAniDBTrakt: CommandRequest_WebCacheSendXRefAniDBTrakt cr_WebCache_SendXRefAniDBTrakt = new CommandRequest_WebCacheSendXRefAniDBTrakt(); cr_WebCache_SendXRefAniDBTrakt.LoadFromDBCommand(crdb); return((ICommandRequest)cr_WebCache_SendXRefAniDBTrakt); case CommandRequestType.WebCache_DeleteXRefAniDBTrakt: CommandRequest_WebCacheDeleteXRefAniDBTrakt cr_WebCache_DeleteXRefAniDBTrakt = new CommandRequest_WebCacheDeleteXRefAniDBTrakt(); cr_WebCache_DeleteXRefAniDBTrakt.LoadFromDBCommand(crdb); return((ICommandRequest)cr_WebCache_DeleteXRefAniDBTrakt); case CommandRequestType.Trakt_SearchAnime: CommandRequest_TraktSearchAnime cr_Trakt_SearchAnime = new CommandRequest_TraktSearchAnime(); cr_Trakt_SearchAnime.LoadFromDBCommand(crdb); return((ICommandRequest)cr_Trakt_SearchAnime); case CommandRequestType.MovieDB_SearchAnime: CommandRequest_MovieDBSearchAnime cr_MovieDB_SearchAnime = new CommandRequest_MovieDBSearchAnime(); cr_MovieDB_SearchAnime.LoadFromDBCommand(crdb); return((ICommandRequest)cr_MovieDB_SearchAnime); case CommandRequestType.WebCache_DeleteXRefAniDBOther: CommandRequest_WebCacheDeleteXRefAniDBOther cr_SendXRefAniDBOther = new CommandRequest_WebCacheDeleteXRefAniDBOther(); cr_SendXRefAniDBOther.LoadFromDBCommand(crdb); return((ICommandRequest)cr_SendXRefAniDBOther); case CommandRequestType.WebCache_SendXRefAniDBOther: CommandRequest_WebCacheSendXRefAniDBOther cr_WebCacheSendXRefAniDBOther = new CommandRequest_WebCacheSendXRefAniDBOther(); cr_WebCacheSendXRefAniDBOther.LoadFromDBCommand(crdb); return((ICommandRequest)cr_WebCacheSendXRefAniDBOther); case CommandRequestType.AniDB_DeleteFileUDP: CommandRequest_DeleteFileFromMyList cr_AniDB_DeleteFileUDP = new CommandRequest_DeleteFileFromMyList(); cr_AniDB_DeleteFileUDP.LoadFromDBCommand(crdb); return((ICommandRequest)cr_AniDB_DeleteFileUDP); case CommandRequestType.ImageDownload: CommandRequest_DownloadImage cr_ImageDownload = new CommandRequest_DownloadImage(); cr_ImageDownload.LoadFromDBCommand(crdb); return((ICommandRequest)cr_ImageDownload); case CommandRequestType.WebCache_DeleteXRefAniDBTvDB: CommandRequest_WebCacheDeleteXRefAniDBTvDB cr_DeleteXRefAniDBTvDB = new CommandRequest_WebCacheDeleteXRefAniDBTvDB(); cr_DeleteXRefAniDBTvDB.LoadFromDBCommand(crdb); return((ICommandRequest)cr_DeleteXRefAniDBTvDB); case CommandRequestType.WebCache_SendXRefAniDBTvDB: CommandRequest_WebCacheSendXRefAniDBTvDB cr_SendXRefAniDBTvDB = new CommandRequest_WebCacheSendXRefAniDBTvDB(); cr_SendXRefAniDBTvDB.LoadFromDBCommand(crdb); return((ICommandRequest)cr_SendXRefAniDBTvDB); case CommandRequestType.TvDB_SearchAnime: CommandRequest_TvDBSearchAnime cr_TvDB_SearchAnime = new CommandRequest_TvDBSearchAnime(); cr_TvDB_SearchAnime.LoadFromDBCommand(crdb); return((ICommandRequest)cr_TvDB_SearchAnime); case CommandRequestType.TvDB_DownloadImages: CommandRequest_TvDBDownloadImages cr_TvDB_DownloadImages = new CommandRequest_TvDBDownloadImages(); cr_TvDB_DownloadImages.LoadFromDBCommand(crdb); return((ICommandRequest)cr_TvDB_DownloadImages); case CommandRequestType.TvDB_SeriesEpisodes: CommandRequest_TvDBUpdateSeriesAndEpisodes cr_TvDB_Episodes = new CommandRequest_TvDBUpdateSeriesAndEpisodes(); cr_TvDB_Episodes.LoadFromDBCommand(crdb); return((ICommandRequest)cr_TvDB_Episodes); case CommandRequestType.AniDB_SyncVotes: CommandRequest_SyncMyVotes cr_SyncVotes = new CommandRequest_SyncMyVotes(); cr_SyncVotes.LoadFromDBCommand(crdb); return((ICommandRequest)cr_SyncVotes); case CommandRequestType.AniDB_VoteAnime: CommandRequest_VoteAnime cr_VoteAnime = new CommandRequest_VoteAnime(); cr_VoteAnime.LoadFromDBCommand(crdb); return((ICommandRequest)cr_VoteAnime); case CommandRequestType.AniDB_GetCalendar: CommandRequest_GetCalendar cr_GetCalendar = new CommandRequest_GetCalendar(); cr_GetCalendar.LoadFromDBCommand(crdb); return((ICommandRequest)cr_GetCalendar); case CommandRequestType.AniDB_GetReleaseGroup: CommandRequest_GetReleaseGroup cr_GetReleaseGroup = new CommandRequest_GetReleaseGroup(); cr_GetReleaseGroup.LoadFromDBCommand(crdb); return((ICommandRequest)cr_GetReleaseGroup); case CommandRequestType.AniDB_GetAnimeHTTP: CommandRequest_GetAnimeHTTP cr_geth = new CommandRequest_GetAnimeHTTP(); cr_geth.LoadFromDBCommand(crdb); return((ICommandRequest)cr_geth); case CommandRequestType.AniDB_GetReleaseGroupStatus: CommandRequest_GetReleaseGroupStatus cr_GetReleaseGroupStatus = new CommandRequest_GetReleaseGroupStatus(); cr_GetReleaseGroupStatus.LoadFromDBCommand(crdb); return((ICommandRequest)cr_GetReleaseGroupStatus); case CommandRequestType.HashFile: CommandRequest_HashFile cr_HashFile = new CommandRequest_HashFile(); cr_HashFile.LoadFromDBCommand(crdb); return((ICommandRequest)cr_HashFile); case CommandRequestType.ProcessFile: CommandRequest_ProcessFile cr_pf = new CommandRequest_ProcessFile(); cr_pf.LoadFromDBCommand(crdb); return((ICommandRequest)cr_pf); case CommandRequestType.AniDB_AddFileUDP: CommandRequest_AddFileToMyList cr_af = new CommandRequest_AddFileToMyList(); cr_af.LoadFromDBCommand(crdb); return((ICommandRequest)cr_af); case CommandRequestType.AniDB_UpdateWatchedUDP: CommandRequest_UpdateMyListFileStatus cr_umlf = new CommandRequest_UpdateMyListFileStatus(); cr_umlf.LoadFromDBCommand(crdb); return((ICommandRequest)cr_umlf); case CommandRequestType.WebCache_DeleteXRefFileEpisode: CommandRequest_WebCacheDeleteXRefFileEpisode cr_DeleteXRefFileEpisode = new CommandRequest_WebCacheDeleteXRefFileEpisode(); cr_DeleteXRefFileEpisode.LoadFromDBCommand(crdb); return((ICommandRequest)cr_DeleteXRefFileEpisode); case CommandRequestType.WebCache_SendXRefFileEpisode: CommandRequest_WebCacheSendXRefFileEpisode cr_SendXRefFileEpisode = new CommandRequest_WebCacheSendXRefFileEpisode(); cr_SendXRefFileEpisode.LoadFromDBCommand(crdb); return((ICommandRequest)cr_SendXRefFileEpisode); case CommandRequestType.AniDB_GetReviews: CommandRequest_GetReviews cr_GetReviews = new CommandRequest_GetReviews(); cr_GetReviews.LoadFromDBCommand(crdb); return((ICommandRequest)cr_GetReviews); case CommandRequestType.AniDB_GetUpdated: CommandRequest_GetUpdated cr_GetUpdated = new CommandRequest_GetUpdated(); cr_GetUpdated.LoadFromDBCommand(crdb); return((ICommandRequest)cr_GetUpdated); case CommandRequestType.AniDB_SyncMyList: CommandRequest_SyncMyList cr_SyncMyList = new CommandRequest_SyncMyList(); cr_SyncMyList.LoadFromDBCommand(crdb); return((ICommandRequest)cr_SyncMyList); case CommandRequestType.Refresh_AnimeStats: CommandRequest_RefreshAnime cr_refreshAnime = new CommandRequest_RefreshAnime(); cr_refreshAnime.LoadFromDBCommand(crdb); return(cr_refreshAnime); case CommandRequestType.LinkAniDBTvDB: CommandRequest_LinkAniDBTvDB cr_linkAniDBTvDB = new CommandRequest_LinkAniDBTvDB(); cr_linkAniDBTvDB.LoadFromDBCommand(crdb); return(cr_linkAniDBTvDB); } return(null); }
public AnimeSeries CreateAnimeSeriesAndGroup(ISession session) { // create a new AnimeSeries record AnimeSeriesRepository repSeries = new AnimeSeriesRepository(); AnimeGroupRepository repGroups = new AnimeGroupRepository(); AnimeSeries ser = new AnimeSeries(); ser.Populate(this); JMMUserRepository repUsers = new JMMUserRepository(); List<JMMUser> allUsers = repUsers.GetAll(session); // create the AnimeGroup record // check if there are any existing groups we could add this series to bool createNewGroup = true; if (ServerSettings.AutoGroupSeries) { List<AnimeGroup> grps = AnimeGroup.GetRelatedGroupsFromAnimeID(session, ser.AniDB_ID); // only use if there is just one result if (grps != null && grps.Count > 0) { ser.AnimeGroupID = grps[0].AnimeGroupID; createNewGroup = false; } } if (createNewGroup) { AnimeGroup anGroup = new AnimeGroup(); anGroup.Populate(ser); repGroups.Save(anGroup); ser.AnimeGroupID = anGroup.AnimeGroupID; } repSeries.Save(ser); // check for TvDB associations CommandRequest_TvDBSearchAnime cmd = new CommandRequest_TvDBSearchAnime(this.AnimeID, false); cmd.Save(); // check for Trakt associations if (ServerSettings.Trakt_IsEnabled && !string.IsNullOrEmpty(ServerSettings.Trakt_AuthToken)) { CommandRequest_TraktSearchAnime cmd2 = new CommandRequest_TraktSearchAnime(this.AnimeID, false); cmd2.Save(); } return ser; }
// List of Default priorities for commands // Pri 1 //------ // Reserved for commands user manually initiates from UI //------ // Pri 2 //------ // CommandRequest_GetAnimeHTTP //------ // Pri 3 //------ // CommandRequest_ProcessFile // CommandRequest_GetFile //------ // Pri 4 //------ // CommandRequest_GetUpdated // CommandRequest_ReadMediaInfo // CommandRequest_GetEpsode //------ // Pri 5 //------ // CommandRequest_GetReleaseGroupStatus //------ // Pri 6 //------ // CommandRequest_SyncMyList // CommandRequest_SyncMyVotes //------ // Pri 7 //------ // CommandRequest_GetCalendar //------ // Pri 8 //------ // CommandRequest_UpdateMyListFileStatus // CommandRequest_GetCharactersCreators // CommandRequest_TraktSyncCollection // CommandRequest_TvDBUpdateSeriesAndEpisodes // CommandRequest_TvDBDownloadImages // CommandRequest_TvDBSearchAnime // CommandRequest_MovieDBSearchAnime // CommandRequest_TraktSearchAnime // CommandRequest_MALSearchAnime //------ // Pri 9 //------ // CommandRequest_WebCacheSendFileHash // CommandRequest_GetReviews // CommandRequest_GetReleaseGroup // CommandRequest_WebCacheSendXRefFileEpisode // CommandRequest_WebCacheDeleteXRefFileEpisode // CommandRequest_AddFileToMyList // CommandRequest_DeleteFileFromMyList // CommandRequest_VoteAnime // CommandRequest_WebCacheDeleteXRefAniDBTvDB // CommandRequest_WebCacheDeleteXRefAniDBTvDBAll // CommandRequest_WebCacheSendXRefAniDBTvDB // CommandRequest_WebCacheSendXRefAniDBOther // CommandRequest_WebCacheDeleteXRefAniDBOther // CommandRequest_WebCacheDeleteXRefAniDBTrakt // CommandRequest_WebCacheSendXRefAniDBTrakt // CommandRequest_TraktUpdateInfoAndImages // CommandRequest_TraktSyncCollectionSeries // CommandRequest_TraktShowEpisodeUnseen // CommandRequest_DownloadImage // CommandRequest_TraktUpdateAllSeries // CommandRequest_MALUpdatedWatchedStatus // CommandRequest_MALUploadStatusToMAL // CommandRequest_MALDownloadStatusFromMAL // CommandRequest_WebCacheSendAniDB_File // CommandRequest_Azure_SendAnimeFull //------ // Pri 10 //------ // CommandRequest_UpdateMylistStats // CommandRequest_Azure_SendAnimeXML //------ // Pri 11 //------ // CommandRequest_Azure_SendAnimeTitle public static ICommandRequest GetCommand(CommandRequest crdb) { CommandRequestType crt = (CommandRequestType)crdb.CommandType; switch (crt) { case CommandRequestType.Trakt_SyncCollectionSeries: CommandRequest_TraktSyncCollectionSeries cr_CommandRequest_TraktSyncCollectionSeries = new CommandRequest_TraktSyncCollectionSeries(); cr_CommandRequest_TraktSyncCollectionSeries.LoadFromDBCommand(crdb); return (ICommandRequest)cr_CommandRequest_TraktSyncCollectionSeries; case CommandRequestType.AniDB_GetEpisodeUDP: CommandRequest_GetEpisode cr_CommandRequest_GetEpisode = new CommandRequest_GetEpisode(); cr_CommandRequest_GetEpisode.LoadFromDBCommand(crdb); return (ICommandRequest)cr_CommandRequest_GetEpisode; case CommandRequestType.Azure_SendAnimeTitle: CommandRequest_Azure_SendAnimeTitle cr_CommandRequest_Azure_SendAnimeTitle = new CommandRequest_Azure_SendAnimeTitle(); cr_CommandRequest_Azure_SendAnimeTitle.LoadFromDBCommand(crdb); return (ICommandRequest)cr_CommandRequest_Azure_SendAnimeTitle; case CommandRequestType.AniDB_GetTitles: CommandRequest_GetAniDBTitles cr_CommandRequest_GetAniDBTitles = new CommandRequest_GetAniDBTitles(); cr_CommandRequest_GetAniDBTitles.LoadFromDBCommand(crdb); return (ICommandRequest)cr_CommandRequest_GetAniDBTitles; case CommandRequestType.Azure_SendAnimeXML: CommandRequest_Azure_SendAnimeXML cr_CommandRequest_Azure_SendAnimeXML = new CommandRequest_Azure_SendAnimeXML(); cr_CommandRequest_Azure_SendAnimeXML.LoadFromDBCommand(crdb); return (ICommandRequest)cr_CommandRequest_Azure_SendAnimeXML; case CommandRequestType.Azure_SendAnimeFull: CommandRequest_Azure_SendAnimeFull cr_CommandRequest_Azure_SendAnimeFull = new CommandRequest_Azure_SendAnimeFull(); cr_CommandRequest_Azure_SendAnimeFull.LoadFromDBCommand(crdb); return (ICommandRequest)cr_CommandRequest_Azure_SendAnimeFull; case CommandRequestType.Azure_SendUserInfo: CommandRequest_Azure_SendUserInfo cr_CommandRequest_Azure_SendUserInfo = new CommandRequest_Azure_SendUserInfo(); cr_CommandRequest_Azure_SendUserInfo.LoadFromDBCommand(crdb); return (ICommandRequest)cr_CommandRequest_Azure_SendUserInfo; case CommandRequestType.AniDB_UpdateMylistStats: CommandRequest_UpdateMylistStats cr_AniDB_UpdateMylistStats = new CommandRequest_UpdateMylistStats(); cr_AniDB_UpdateMylistStats.LoadFromDBCommand(crdb); return (ICommandRequest)cr_AniDB_UpdateMylistStats; case CommandRequestType.MAL_DownloadWatchedStates: CommandRequest_MALDownloadStatusFromMAL cr_MAL_DownloadWatchedStates = new CommandRequest_MALDownloadStatusFromMAL(); cr_MAL_DownloadWatchedStates.LoadFromDBCommand(crdb); return (ICommandRequest)cr_MAL_DownloadWatchedStates; case CommandRequestType.MAL_UploadWatchedStates: CommandRequest_MALUploadStatusToMAL cr_MAL_UploadWatchedStates = new CommandRequest_MALUploadStatusToMAL(); cr_MAL_UploadWatchedStates.LoadFromDBCommand(crdb); return (ICommandRequest)cr_MAL_UploadWatchedStates; case CommandRequestType.MAL_UpdateStatus: CommandRequest_MALUpdatedWatchedStatus cr_MAL_UpdateStatus = new CommandRequest_MALUpdatedWatchedStatus(); cr_MAL_UpdateStatus.LoadFromDBCommand(crdb); return (ICommandRequest)cr_MAL_UpdateStatus; case CommandRequestType.MAL_SearchAnime: CommandRequest_MALSearchAnime cr_MAL_SearchAnime = new CommandRequest_MALSearchAnime(); cr_MAL_SearchAnime.LoadFromDBCommand(crdb); return (ICommandRequest)cr_MAL_SearchAnime; case CommandRequestType.WebCache_SendXRefAniDBMAL: CommandRequest_WebCacheSendXRefAniDBMAL cr_WebCacheSendXRefAniDBMAL = new CommandRequest_WebCacheSendXRefAniDBMAL(); cr_WebCacheSendXRefAniDBMAL.LoadFromDBCommand(crdb); return (ICommandRequest)cr_WebCacheSendXRefAniDBMAL; case CommandRequestType.WebCache_DeleteXRefAniDBMAL: CommandRequest_WebCacheDeleteXRefAniDBMAL cr_WebCacheDeleteXRefAniDBMAL = new CommandRequest_WebCacheDeleteXRefAniDBMAL(); cr_WebCacheDeleteXRefAniDBMAL.LoadFromDBCommand(crdb); return (ICommandRequest)cr_WebCacheDeleteXRefAniDBMAL; case CommandRequestType.AniDB_GetFileUDP: CommandRequest_GetFile cr_AniDB_GetFileUDP = new CommandRequest_GetFile(); cr_AniDB_GetFileUDP.LoadFromDBCommand(crdb); return (ICommandRequest)cr_AniDB_GetFileUDP; case CommandRequestType.ReadMediaInfo: CommandRequest_ReadMediaInfo cr_ReadMediaInfo = new CommandRequest_ReadMediaInfo(); cr_ReadMediaInfo.LoadFromDBCommand(crdb); return (ICommandRequest)cr_ReadMediaInfo; case CommandRequestType.Trakt_UpdateAllSeries: CommandRequest_TraktUpdateAllSeries cr_Trakt_UpdateAllSeries = new CommandRequest_TraktUpdateAllSeries(); cr_Trakt_UpdateAllSeries.LoadFromDBCommand(crdb); return (ICommandRequest)cr_Trakt_UpdateAllSeries; case CommandRequestType.Trakt_EpisodeCollection: CommandRequest_TraktCollectionEpisode cr_TraktCollectionEpisode = new CommandRequest_TraktCollectionEpisode(); cr_TraktCollectionEpisode.LoadFromDBCommand(crdb); return (ICommandRequest)cr_TraktCollectionEpisode; case CommandRequestType.Trakt_SyncCollection: CommandRequest_TraktSyncCollection cr_Trakt_SyncCollection = new CommandRequest_TraktSyncCollection(); cr_Trakt_SyncCollection.LoadFromDBCommand(crdb); return (ICommandRequest)cr_Trakt_SyncCollection; case CommandRequestType.Trakt_EpisodeHistory: CommandRequest_TraktHistoryEpisode cr_Trakt_EpisodeHistory = new CommandRequest_TraktHistoryEpisode(); cr_Trakt_EpisodeHistory.LoadFromDBCommand(crdb); return (ICommandRequest)cr_Trakt_EpisodeHistory; case CommandRequestType.Trakt_UpdateInfoImages: CommandRequest_TraktUpdateInfoAndImages cr_Trakt_UpdateInfoImages = new CommandRequest_TraktUpdateInfoAndImages(); cr_Trakt_UpdateInfoImages.LoadFromDBCommand(crdb); return (ICommandRequest)cr_Trakt_UpdateInfoImages; case CommandRequestType.WebCache_SendXRefAniDBTrakt: CommandRequest_WebCacheSendXRefAniDBTrakt cr_WebCache_SendXRefAniDBTrakt = new CommandRequest_WebCacheSendXRefAniDBTrakt(); cr_WebCache_SendXRefAniDBTrakt.LoadFromDBCommand(crdb); return (ICommandRequest)cr_WebCache_SendXRefAniDBTrakt; case CommandRequestType.WebCache_DeleteXRefAniDBTrakt: CommandRequest_WebCacheDeleteXRefAniDBTrakt cr_WebCache_DeleteXRefAniDBTrakt = new CommandRequest_WebCacheDeleteXRefAniDBTrakt(); cr_WebCache_DeleteXRefAniDBTrakt.LoadFromDBCommand(crdb); return (ICommandRequest)cr_WebCache_DeleteXRefAniDBTrakt; case CommandRequestType.Trakt_SearchAnime: CommandRequest_TraktSearchAnime cr_Trakt_SearchAnime = new CommandRequest_TraktSearchAnime(); cr_Trakt_SearchAnime.LoadFromDBCommand(crdb); return (ICommandRequest)cr_Trakt_SearchAnime; case CommandRequestType.MovieDB_SearchAnime: CommandRequest_MovieDBSearchAnime cr_MovieDB_SearchAnime = new CommandRequest_MovieDBSearchAnime(); cr_MovieDB_SearchAnime.LoadFromDBCommand(crdb); return (ICommandRequest)cr_MovieDB_SearchAnime; case CommandRequestType.WebCache_DeleteXRefAniDBOther: CommandRequest_WebCacheDeleteXRefAniDBOther cr_SendXRefAniDBOther = new CommandRequest_WebCacheDeleteXRefAniDBOther(); cr_SendXRefAniDBOther.LoadFromDBCommand(crdb); return (ICommandRequest)cr_SendXRefAniDBOther; case CommandRequestType.WebCache_SendXRefAniDBOther: CommandRequest_WebCacheSendXRefAniDBOther cr_WebCacheSendXRefAniDBOther = new CommandRequest_WebCacheSendXRefAniDBOther(); cr_WebCacheSendXRefAniDBOther.LoadFromDBCommand(crdb); return (ICommandRequest)cr_WebCacheSendXRefAniDBOther; case CommandRequestType.AniDB_DeleteFileUDP: CommandRequest_DeleteFileFromMyList cr_AniDB_DeleteFileUDP = new CommandRequest_DeleteFileFromMyList(); cr_AniDB_DeleteFileUDP.LoadFromDBCommand(crdb); return (ICommandRequest)cr_AniDB_DeleteFileUDP; case CommandRequestType.ImageDownload: CommandRequest_DownloadImage cr_ImageDownload = new CommandRequest_DownloadImage(); cr_ImageDownload.LoadFromDBCommand(crdb); return (ICommandRequest)cr_ImageDownload; case CommandRequestType.WebCache_DeleteXRefAniDBTvDB: CommandRequest_WebCacheDeleteXRefAniDBTvDB cr_DeleteXRefAniDBTvDB = new CommandRequest_WebCacheDeleteXRefAniDBTvDB(); cr_DeleteXRefAniDBTvDB.LoadFromDBCommand(crdb); return (ICommandRequest)cr_DeleteXRefAniDBTvDB; case CommandRequestType.WebCache_SendXRefAniDBTvDB: CommandRequest_WebCacheSendXRefAniDBTvDB cr_SendXRefAniDBTvDB = new CommandRequest_WebCacheSendXRefAniDBTvDB(); cr_SendXRefAniDBTvDB.LoadFromDBCommand(crdb); return (ICommandRequest)cr_SendXRefAniDBTvDB; case CommandRequestType.TvDB_SearchAnime: CommandRequest_TvDBSearchAnime cr_TvDB_SearchAnime = new CommandRequest_TvDBSearchAnime(); cr_TvDB_SearchAnime.LoadFromDBCommand(crdb); return (ICommandRequest)cr_TvDB_SearchAnime; case CommandRequestType.TvDB_DownloadImages: CommandRequest_TvDBDownloadImages cr_TvDB_DownloadImages = new CommandRequest_TvDBDownloadImages(); cr_TvDB_DownloadImages.LoadFromDBCommand(crdb); return (ICommandRequest)cr_TvDB_DownloadImages; case CommandRequestType.TvDB_SeriesEpisodes: CommandRequest_TvDBUpdateSeriesAndEpisodes cr_TvDB_Episodes = new CommandRequest_TvDBUpdateSeriesAndEpisodes(); cr_TvDB_Episodes.LoadFromDBCommand(crdb); return (ICommandRequest)cr_TvDB_Episodes; case CommandRequestType.AniDB_SyncVotes: CommandRequest_SyncMyVotes cr_SyncVotes = new CommandRequest_SyncMyVotes(); cr_SyncVotes.LoadFromDBCommand(crdb); return (ICommandRequest)cr_SyncVotes; case CommandRequestType.AniDB_VoteAnime: CommandRequest_VoteAnime cr_VoteAnime = new CommandRequest_VoteAnime(); cr_VoteAnime.LoadFromDBCommand(crdb); return (ICommandRequest)cr_VoteAnime; case CommandRequestType.AniDB_GetCalendar: CommandRequest_GetCalendar cr_GetCalendar = new CommandRequest_GetCalendar(); cr_GetCalendar.LoadFromDBCommand(crdb); return (ICommandRequest)cr_GetCalendar; case CommandRequestType.AniDB_GetReleaseGroup: CommandRequest_GetReleaseGroup cr_GetReleaseGroup = new CommandRequest_GetReleaseGroup(); cr_GetReleaseGroup.LoadFromDBCommand(crdb); return (ICommandRequest)cr_GetReleaseGroup; case CommandRequestType.AniDB_GetAnimeHTTP: CommandRequest_GetAnimeHTTP cr_geth = new CommandRequest_GetAnimeHTTP(); cr_geth.LoadFromDBCommand(crdb); return (ICommandRequest)cr_geth; case CommandRequestType.AniDB_GetReleaseGroupStatus: CommandRequest_GetReleaseGroupStatus cr_GetReleaseGroupStatus = new CommandRequest_GetReleaseGroupStatus(); cr_GetReleaseGroupStatus.LoadFromDBCommand(crdb); return (ICommandRequest)cr_GetReleaseGroupStatus; case CommandRequestType.HashFile: CommandRequest_HashFile cr_HashFile = new CommandRequest_HashFile(); cr_HashFile.LoadFromDBCommand(crdb); return (ICommandRequest)cr_HashFile; case CommandRequestType.ProcessFile: CommandRequest_ProcessFile cr_pf = new CommandRequest_ProcessFile(); cr_pf.LoadFromDBCommand(crdb); return (ICommandRequest)cr_pf; case CommandRequestType.AniDB_AddFileUDP: CommandRequest_AddFileToMyList cr_af = new CommandRequest_AddFileToMyList(); cr_af.LoadFromDBCommand(crdb); return (ICommandRequest)cr_af; case CommandRequestType.AniDB_UpdateWatchedUDP: CommandRequest_UpdateMyListFileStatus cr_umlf = new CommandRequest_UpdateMyListFileStatus(); cr_umlf.LoadFromDBCommand(crdb); return (ICommandRequest)cr_umlf; case CommandRequestType.WebCache_DeleteXRefFileEpisode: CommandRequest_WebCacheDeleteXRefFileEpisode cr_DeleteXRefFileEpisode = new CommandRequest_WebCacheDeleteXRefFileEpisode(); cr_DeleteXRefFileEpisode.LoadFromDBCommand(crdb); return (ICommandRequest)cr_DeleteXRefFileEpisode; case CommandRequestType.WebCache_SendXRefFileEpisode: CommandRequest_WebCacheSendXRefFileEpisode cr_SendXRefFileEpisode = new CommandRequest_WebCacheSendXRefFileEpisode(); cr_SendXRefFileEpisode.LoadFromDBCommand(crdb); return (ICommandRequest)cr_SendXRefFileEpisode; case CommandRequestType.AniDB_GetReviews: CommandRequest_GetReviews cr_GetReviews = new CommandRequest_GetReviews(); cr_GetReviews.LoadFromDBCommand(crdb); return (ICommandRequest)cr_GetReviews; case CommandRequestType.AniDB_GetUpdated: CommandRequest_GetUpdated cr_GetUpdated = new CommandRequest_GetUpdated(); cr_GetUpdated.LoadFromDBCommand(crdb); return (ICommandRequest)cr_GetUpdated; case CommandRequestType.AniDB_SyncMyList: CommandRequest_SyncMyList cr_SyncMyList = new CommandRequest_SyncMyList(); cr_SyncMyList.LoadFromDBCommand(crdb); return (ICommandRequest)cr_SyncMyList; case CommandRequestType.Refresh_AnimeStats: CommandRequest_RefreshAnime cr_refreshAnime=new CommandRequest_RefreshAnime(); cr_refreshAnime.LoadFromDBCommand(crdb); return cr_refreshAnime; } return null; }
public Contract_AnimeSeries_SaveResponse CreateSeriesFromAnime(int animeID, int? animeGroupID, int userID) { Contract_AnimeSeries_SaveResponse response = new Contract_AnimeSeries_SaveResponse(); response.AnimeSeries = null; response.ErrorMessage = ""; try { using (var session = DatabaseFactory.SessionFactory.OpenSession()) { ISessionWrapper sessionWrapper = session.Wrap(); if (animeGroupID.HasValue) { AnimeGroup grp = RepoFactory.AnimeGroup.GetByID(animeGroupID.Value); if (grp == null) { response.ErrorMessage = "Could not find the specified group"; return response; } } // make sure a series doesn't already exists for this anime AnimeSeries ser = RepoFactory.AnimeSeries.GetByAnimeID(animeID); if (ser != null) { response.ErrorMessage = "A series already exists for this anime"; return response; } // make sure the anime exists first AniDB_Anime anime = RepoFactory.AniDB_Anime.GetByAnimeID(sessionWrapper, animeID); if (anime == null) anime = JMMService.AnidbProcessor.GetAnimeInfoHTTP(session, animeID, false, false); if (anime == null) { response.ErrorMessage = "Could not get anime information from AniDB"; return response; } if (animeGroupID.HasValue) { ser = new AnimeSeries(); ser.Populate(anime); ser.AnimeGroupID = animeGroupID.Value; RepoFactory.AnimeSeries.Save(ser, false); } else { ser = anime.CreateAnimeSeriesAndGroup(sessionWrapper); } ser.CreateAnimeEpisodes(session); // check if we have any group status data for this associated anime // if not we will download it now if (RepoFactory.AniDB_GroupStatus.GetByAnimeID(anime.AnimeID).Count == 0) { CommandRequest_GetReleaseGroupStatus cmdStatus = new CommandRequest_GetReleaseGroupStatus(anime.AnimeID, false); cmdStatus.Save(session); } ser.UpdateStats(true, true, true); // check for TvDB associations CommandRequest_TvDBSearchAnime cmd = new CommandRequest_TvDBSearchAnime(anime.AnimeID, false); cmd.Save(session); if (ServerSettings.Trakt_IsEnabled && !string.IsNullOrEmpty(ServerSettings.Trakt_AuthToken)) { // check for Trakt associations CommandRequest_TraktSearchAnime cmd2 = new CommandRequest_TraktSearchAnime(anime.AnimeID, false); cmd2.Save(session); } response.AnimeSeries = ser.GetUserContract(userID); return response; } } catch (Exception ex) { logger.Error( ex,ex.ToString()); response.ErrorMessage = ex.Message; } return response; }
public AnimeSeries CreateAnimeSeriesAndGroup(ISessionWrapper session) { // Create a new AnimeSeries record AnimeSeries series = new AnimeSeries(); series.Populate(this); AnimeGroup grp = new AnimeGroupCreator().GetOrCreateSingleGroupForSeries(session, series); series.AnimeGroupID = grp.AnimeGroupID; RepoFactory.AnimeSeries.Save(series, false, false); // check for TvDB associations CommandRequest_TvDBSearchAnime cmd = new CommandRequest_TvDBSearchAnime(AnimeID, forced: false); cmd.Save(); // check for Trakt associations if (ServerSettings.Trakt_IsEnabled && !String.IsNullOrEmpty(ServerSettings.Trakt_AuthToken)) { CommandRequest_TraktSearchAnime cmd2 = new CommandRequest_TraktSearchAnime(AnimeID, forced: false); cmd2.Save(); } return series; }
public static string LinkAniDBTvDB(int animeID, enEpisodeType aniEpType, int aniEpNumber, int tvDBID, int tvSeasonNumber, int tvEpNumber, bool excludeFromWebCache, bool additiveLink=false) { using (var session = DatabaseFactory.SessionFactory.OpenSession()) { if(!additiveLink) // remove all current links RemoveAllAniDBTvDBLinks(session.Wrap(), animeID); // check if we have this information locally // if not download it now TvDB_Series tvSeries = RepoFactory.TvDB_Series.GetByTvDBID(tvDBID); if (tvSeries == null) { // we download the series info here just so that we have the basic info in the // database before the queued task runs later tvSeries = GetSeriesInfoOnline(tvDBID); } // download and update series info, episode info and episode images // will also download fanart, posters and wide banners CommandRequest_TvDBUpdateSeriesAndEpisodes cmdSeriesEps = new CommandRequest_TvDBUpdateSeriesAndEpisodes(tvDBID, false); //Optimize for batch updates, if there are a lot of LinkAniDBTvDB commands queued //this will cause only one updateSeriesAndEpisodes command to be created if (RepoFactory.CommandRequest.GetByCommandID(cmdSeriesEps.CommandID) == null) { cmdSeriesEps.Save(); } CrossRef_AniDB_TvDBV2 xref = RepoFactory.CrossRef_AniDB_TvDBV2.GetByTvDBID(session, tvDBID, tvSeasonNumber, tvEpNumber, animeID, (int) aniEpType, aniEpNumber); if (xref == null) xref = new CrossRef_AniDB_TvDBV2(); xref.AnimeID = animeID; xref.AniDBStartEpisodeType = (int) aniEpType; xref.AniDBStartEpisodeNumber = aniEpNumber; xref.TvDBID = tvDBID; xref.TvDBSeasonNumber = tvSeasonNumber; xref.TvDBStartEpisodeNumber = tvEpNumber; if (tvSeries != null) xref.TvDBTitle = tvSeries.SeriesName; if (excludeFromWebCache) xref.CrossRefSource = (int) CrossRefSource.WebCache; else xref.CrossRefSource = (int) CrossRefSource.User; RepoFactory.CrossRef_AniDB_TvDBV2.Save(xref); AniDB_Anime.UpdateStatsByAnimeID(animeID); logger.Trace("Changed tvdb association: {0}", animeID); if (!excludeFromWebCache) { CommandRequest_WebCacheSendXRefAniDBTvDB req = new CommandRequest_WebCacheSendXRefAniDBTvDB(xref.CrossRef_AniDB_TvDBV2ID); req.Save(); } if (ServerSettings.Trakt_IsEnabled && !string.IsNullOrEmpty(ServerSettings.Trakt_AuthToken)) { if (RepoFactory.CrossRef_AniDB_TraktV2.GetByAnimeID(animeID).Count == 0) { // check for Trakt associations CommandRequest_TraktSearchAnime cmd2 = new CommandRequest_TraktSearchAnime(animeID, false); cmd2.Save(session); } } } return ""; }