public void RemoveBrokenLinks(CommandSystem.ExecutionInformation info) { const int iterations = 3; var currentIter = audioLogEntries.FindAll().ToList(); for (int i = 0; i < iterations; i++) { info.Write("Filter iteration " + i); currentIter = FilterList(info, currentIter); } foreach (var entry in currentIter) { RemoveEntry(entry); info.Bot.PlaylistManager.AddToTrash(new PlaylistItem(entry.AudioResource)); info.Write($"Removed: {entry.Id} - {entry.AudioResource.ResourceTitle}"); } }
/// <summary> /// Goes through a list of <see cref="AudioLogEntry"/> and checks if the contained <see cref="AudioResource"/> /// is playable/resolveable. /// </summary> /// <param name="session">Session object to inform the user about the current cleaning status.</param> /// <param name="list">The list to iterate.</param> /// <returns>A new list with all working items.</returns> private static List <AudioLogEntry> FilterList(CommandSystem.ExecutionInformation info, IEnumerable <AudioLogEntry> list) { int userNotityCnt = 0; var nextIter = new List <AudioLogEntry>(); foreach (var entry in list) { var result = info.Bot.FactoryManager.Load(entry.AudioResource); if (!result) { info.Write($"//DEBUG// ({entry.AudioResource.UniqueId}) Reason: {result.Message}"); nextIter.Add(entry); } if (++userNotityCnt % 100 == 0) { info.Write("Working" + new string('.', userNotityCnt / 100)); } } return(nextIter); }