Exemplo n.º 1
0
		public static void FixDuplicateTraktLinks()
		{
			AniDB_AnimeRepository repAnime = new AniDB_AnimeRepository();

			// delete all Trakt link duplicates
			CrossRef_AniDB_TraktRepository repCrossRefTrakt = new CrossRef_AniDB_TraktRepository();

			List<CrossRef_AniDB_Trakt> xrefsTraktProcessed = new List<CrossRef_AniDB_Trakt>();
			List<CrossRef_AniDB_Trakt> xrefsTraktToBeDeleted = new List<CrossRef_AniDB_Trakt>();

			List<CrossRef_AniDB_Trakt> xrefsTrakt = repCrossRefTrakt.GetAll();
			foreach (CrossRef_AniDB_Trakt xrefTrakt in xrefsTrakt)
			{
				bool deleteXref = false;
				foreach (CrossRef_AniDB_Trakt xref in xrefsTraktProcessed)
				{
					if (xref.TraktID == xrefTrakt.TraktID && xref.TraktSeasonNumber == xrefTrakt.TraktSeasonNumber)
					{
						xrefsTraktToBeDeleted.Add(xrefTrakt);
						deleteXref = true;
					}
				}
				if (!deleteXref)
					xrefsTraktProcessed.Add(xrefTrakt);
			}


			foreach (CrossRef_AniDB_Trakt xref in xrefsTraktToBeDeleted)
			{
				string msg = "";
				AniDB_Anime anime = repAnime.GetByAnimeID(xref.AnimeID);
				if (anime != null) msg = anime.MainTitle;

				logger.Warn("Deleting Trakt Link because of a duplicate: {0} ({1}) - {2}/{3}", xref.AnimeID, msg, xref.TraktID, xref.TraktSeasonNumber);
				repCrossRefTrakt.Delete(xref.CrossRef_AniDB_TraktID);
			}
		}
Exemplo n.º 2
0
		// Removes all Trakt information from a series, bringing it back to a blank state.
		public static void RemoveLinkAniDBTrakt(AnimeSeries ser)
		{
			CrossRef_AniDB_TraktRepository repCrossRef = new CrossRef_AniDB_TraktRepository();
			CrossRef_AniDB_Trakt xref = repCrossRef.GetByAnimeID(ser.AniDB_ID);
			if (xref == null) return;

			repCrossRef.Delete(xref.CrossRef_AniDB_TraktID);

			CommandRequest_WebCacheDeleteXRefAniDBTrakt req = new CommandRequest_WebCacheDeleteXRefAniDBTrakt(ser.AniDB_ID);
			req.Save();
		}