private static void FindMissingEpisodes() { Hashtable paths = new Hashtable(); foreach (MediaFile ie in MediaFileManager.Instance) { if (!string.IsNullOrEmpty(ie.Showname)) { if (paths.ContainsKey(ie.Showname + ie.SeasonNr)) { if (((EpisodeCollection)paths[ie.Showname + ie.SeasonNr]).maxEpisode < ie.EpisodeNr) { ((EpisodeCollection)paths[ie.Showname + ie.SeasonNr]).maxEpisode = ie.EpisodeNr; } if (((EpisodeCollection)paths[ie.Showname + ie.SeasonNr]).minEpisode > ie.EpisodeNr) { ((EpisodeCollection)paths[ie.Showname + ie.SeasonNr]).minEpisode = ie.EpisodeNr; } ((EpisodeCollection)paths[ie.Showname + ie.SeasonNr]).entries.Add(ie); } else { EpisodeCollection ec = new EpisodeCollection(); ec.maxEpisode = ie.EpisodeNr; ec.minEpisode = ie.EpisodeNr; ec.entries.Add(ie); paths.Add(ie.Showname + ie.SeasonNr, ec); } } } foreach (string key in paths.Keys) { int missing = 0; string message = "Missing episodes in " + ((EpisodeCollection)paths[key]).entries[0].Showname + " Season " + ((EpisodeCollection)paths[key]).entries[0].SeasonNr + ": "; string premessage = ""; string postmessage = ""; for (int i = 1; i <= ((EpisodeCollection)paths[key]).maxEpisode; i++) { bool found = false; foreach (MediaFile ie in ((EpisodeCollection)paths[key]).entries) { if (ie.EpisodeNr == i) { found = true; break; } } if (!found) { if (i < ((EpisodeCollection)paths[key]).minEpisode) { premessage += String.Format("E{0:00}, ", i); } else { postmessage += String.Format("E{0:00}, ", i); } missing += 1; } } if (missing > 0) { //if not too many missing episodes were found, add the lower missing episodes too if (missing < ((EpisodeCollection)paths[key]).entries.Count) { message += premessage; } message += postmessage; //if something is to be reported if (postmessage != "" || missing < ((EpisodeCollection)paths[key]).entries.Count) { message = message.Substring(0, message.Length - 2); log.Info(message); } } } }