using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using MediaBrowser.Controller.IO; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Entities.TV; namespace MediaBrowser.Controller.Resolvers { public static class EntityResolutionHelper { /// /// Any folder named in this list will be ignored - can be added to at runtime for extensibility /// public static List IgnoreFolders = new List() { "trailers", "bdmv", "certificate", "backup", "video_ts", "audio_ts", "ps3_update", "ps3_vprm", "adv_obj", "hvdvd_ts" }; /// /// Determines whether a path should be resolved or ignored entirely - called before we even look at the contents /// /// /// false if the path should be ignored public static bool ShouldResolvePath(WIN32_FIND_DATA path) { bool resolve = true; // Ignore hidden files and folders if (path.IsHidden || path.IsSystemFile) { resolve = false; } // Ignore any folders in our list else if (path.IsDirectory && IgnoreFolders.Contains(Path.GetFileName(path.Path), StringComparer.OrdinalIgnoreCase)) { resolve = false; } return resolve; } /// /// Determines whether a path should be ignored based on its contents - called after the contents have been read /// public static bool ShouldResolvePathContents(ItemResolveEventArgs args) { bool resolve = true; if (args.ContainsFile(".ignore")) { // Ignore any folders containing a file called .ignore resolve = false; } else if (args.IsMetadataFolder) { // Don't retrieve these children here - we'll get them in the season resolver resolve = false; } return resolve; } } }