// 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); }
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(); } }
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) { List <JMMServer.Providers.Azure.CrossRef_File_Episode> xrefs = JMMServer.Providers.Azure.AzureWebAPI.Get_CrossRefFileEpisode(vidLocal); crossRefs = new List <CrossRef_File_Episode>(); if (xrefs == null || xrefs.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 (JMMServer.Providers.Azure.CrossRef_File_Episode xref in xrefs) { CrossRef_File_Episode xrefEnt = new CrossRef_File_Episode(); xrefEnt.Hash = vidLocal.ED2KHash; xrefEnt.FileName = Path.GetFileName(vidLocal.FullServerPath); xrefEnt.FileSize = vidLocal.FileSize; xrefEnt.CrossRefSource = (int)JMMServer.CrossRefSource.WebCache; xrefEnt.AnimeID = animeID; xrefEnt.EpisodeID = xref.EpisodeID; xrefEnt.Percentage = xref.Percentage; xrefEnt.EpisodeOrder = xref.EpisodeOrder; crossRefs.Add(xrefEnt); // in this case we need to save the cross refs manually as AniDB did not provide them repXrefFE.Save(xrefEnt); } } } 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...."); 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) { if (ServerSettings.WebCache_Trakt_Send && !string.IsNullOrEmpty(ServerSettings.Trakt_Username)) { 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(); } }
public string SyncTraktSeries(int animeID) { try { AnimeSeriesRepository repSeries = new AnimeSeriesRepository(); AnimeSeries ser = repSeries.GetByAnimeID(animeID); if (ser == null) return "Could not find Anime Series"; CommandRequest_TraktSyncCollectionSeries cmd = new CommandRequest_TraktSyncCollectionSeries(ser.AnimeSeriesID, ser.GetSeriesName()); cmd.Save(); return string.Empty; } catch (Exception ex) { logger.ErrorException(ex.ToString(), ex); return ex.Message; } }
public string AssociateMultipleFiles(List<int> videoLocalIDs, int animeSeriesID, int startingEpisodeNumber, bool singleEpisode) { try { CrossRef_File_EpisodeRepository repXRefs = new CrossRef_File_EpisodeRepository(); AnimeSeriesRepository repSeries = new AnimeSeriesRepository(); VideoLocalRepository repVids = new VideoLocalRepository(); AniDB_EpisodeRepository repAniEps = new AniDB_EpisodeRepository(); AnimeEpisodeRepository repEps = new AnimeEpisodeRepository(); AnimeSeries ser = repSeries.GetByID(animeSeriesID); if (ser == null) return "Could not find anime series record"; int epNumber = startingEpisodeNumber; int count = 1; foreach (int videoLocalID in videoLocalIDs) { VideoLocal vid = repVids.GetByID(videoLocalID); if (vid == null) return "Could not find video local record"; List<AniDB_Episode> anieps = repAniEps.GetByAnimeIDAndEpisodeNumber(ser.AniDB_ID, epNumber); if (anieps.Count == 0) return "Could not find the AniDB episode record"; AniDB_Episode aniep = anieps[0]; List<AnimeEpisode> eps = repEps.GetByAniEpisodeIDAndSeriesID(aniep.EpisodeID, ser.AnimeSeriesID); if (eps.Count == 0) return "Could not find episode record"; AnimeEpisode ep = eps[0]; CrossRef_File_Episode xref = new CrossRef_File_Episode(); xref.PopulateManually(vid, ep); // TODO do this properly if (singleEpisode) { xref.EpisodeOrder = count; if (videoLocalIDs.Count > 5) xref.Percentage = 100; else xref.Percentage = GetEpisodePercentages(videoLocalIDs.Count)[count - 1]; } repXRefs.Save(xref); vid.RenameIfRequired(); vid.MoveFileIfRequired(); CommandRequest_WebCacheSendXRefFileEpisode cr = new CommandRequest_WebCacheSendXRefFileEpisode(xref.CrossRef_File_EpisodeID); cr.Save(); count++; if (!singleEpisode) epNumber++; } ser.UpdateStats(true, true, true); // update epidsode added 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); } // 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(); } } catch (Exception ex) { logger.ErrorException(ex.ToString(), ex); } return ""; }
public string AssociateSingleFileWithMultipleEpisodes(int videoLocalID, int animeSeriesID, int startEpNum, int endEpNum) { try { VideoLocalRepository repVids = new VideoLocalRepository(); VideoLocal vid = repVids.GetByID(videoLocalID); if (vid == null) return "Could not find video record"; AnimeEpisodeRepository repEps = new AnimeEpisodeRepository(); AnimeSeriesRepository repSeries = new AnimeSeriesRepository(); AniDB_EpisodeRepository repAniEps = new AniDB_EpisodeRepository(); CrossRef_File_EpisodeRepository repXRefs = new CrossRef_File_EpisodeRepository(); AnimeSeries ser = repSeries.GetByID(animeSeriesID); if (ser == null) return "Could not find anime series record"; for (int i = startEpNum; i <= endEpNum; i++) { List<AniDB_Episode> anieps = repAniEps.GetByAnimeIDAndEpisodeNumber(ser.AniDB_ID, i); if (anieps.Count == 0) return "Could not find the AniDB episode record"; AniDB_Episode aniep = anieps[0]; List<AnimeEpisode> eps = repEps.GetByAniEpisodeIDAndSeriesID(aniep.EpisodeID, ser.AnimeSeriesID); if (eps.Count == 0) return "Could not find episode record"; AnimeEpisode ep = eps[0]; CrossRef_File_Episode xref = new CrossRef_File_Episode(); xref.PopulateManually(vid, ep); repXRefs.Save(xref); CommandRequest_WebCacheSendXRefFileEpisode cr = new CommandRequest_WebCacheSendXRefFileEpisode(xref.CrossRef_File_EpisodeID); cr.Save(); } vid.RenameIfRequired(); vid.MoveFileIfRequired(); ser.UpdateStats(true, true, true); // update epidsode added 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); } // 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(); } return ""; } catch (Exception ex) { logger.ErrorException(ex.ToString(), ex); } return ""; }
public string AssociateSingleFile(int videoLocalID, int animeEpisodeID) { try { VideoLocalRepository repVids = new VideoLocalRepository(); VideoLocal vid = repVids.GetByID(videoLocalID); if (vid == null) return "Could not find video record"; AnimeEpisodeRepository repEps = new AnimeEpisodeRepository(); AnimeEpisode ep = repEps.GetByID(animeEpisodeID); if (ep == null) return "Could not find episode record"; CrossRef_File_EpisodeRepository repXRefs = new CrossRef_File_EpisodeRepository(); CrossRef_File_Episode xref = new CrossRef_File_Episode(); try { xref.PopulateManually(vid, ep); } catch (Exception ex) { string msg = string.Format("Error populating XREF: {0}", vid.ToStringDetailed()); throw; } repXRefs.Save(xref); vid.RenameIfRequired(); vid.MoveFileIfRequired(); CommandRequest_WebCacheSendXRefFileEpisode cr = new CommandRequest_WebCacheSendXRefFileEpisode(xref.CrossRef_File_EpisodeID); cr.Save(); AnimeSeries ser = ep.GetAnimeSeries(); ser.UpdateStats(true, true, true); // update epidsode added stats AnimeSeriesRepository repSeries = new AnimeSeriesRepository(); ser.EpisodeAddedDate = DateTime.Now; repSeries.Save(ser); AnimeGroupRepository repGroups = new AnimeGroupRepository(); foreach (AnimeGroup grp in ser.AllGroupsAbove) { grp.EpisodeAddedDate = DateTime.Now; repGroups.Save(grp); } CommandRequest_AddFileToMyList cmdAddFile = new CommandRequest_AddFileToMyList(vid.Hash); cmdAddFile.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(); } return ""; } catch (Exception ex) { logger.ErrorException(ex.ToString(), ex); } return ""; }
// 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 static void SyncCollectionToTrakt() { try { if (string.IsNullOrEmpty(ServerSettings.Trakt_Username) || string.IsNullOrEmpty(ServerSettings.Trakt_Password)) return; AnimeSeriesRepository repSeries = new AnimeSeriesRepository(); List<AnimeSeries> allSeries = repSeries.GetAll(); foreach (AnimeSeries series in allSeries) { //SyncCollectionToTrakt_Series(series); CommandRequest_TraktSyncCollectionSeries cmd = new CommandRequest_TraktSyncCollectionSeries(series.AnimeSeriesID, series.GetAnime().MainTitle); cmd.Save(); } } catch (Exception ex) { logger.ErrorException("Error in TraktTVHelper.SyncCollectionToTrakt: " + ex.ToString(), ex); } }