/// <summary> /// Thread method that looks for the files and sends /// them to the HandBrakeEncoderProcessor /// </summary> private void SearchForFiles() { if (!Directory.Exists(searchDirectory)) { throw new DirectoryNotFoundException($"Could not find directory {searchDirectory}"); } while (true) { string[] files = Directory.GetFiles(searchDirectory, "*.mkv", SearchOption.AllDirectories); if (files == null || files.Length == 0 || files.All(p => seenFiles.Contains(p))) { logger.Log("Couldn't find any files. Sleeping"); // Couldn't find any files. Sleep and try again in some time Thread.Sleep(SEARCH_SLEEP_TIME_MS); continue; } // Found some items. Begin adding them to the queue foreach (string filePath in files) { if (!seenFiles.Contains(filePath)) { logger.Log($"Found file {filePath}"); seenFiles.Add(filePath); HandBrakeEncoderProcessor.AddWorkItem( new HandBrakeWorkItem( filePath, GetDestinationDirectoryFromFile(filePath), expectedMediaType)); } } } }
protected override void OnStop() { StopFileSearchers(); HandBrakeEncoderProcessor.StopProcessor(); }
private void InitializeProcessor() { HandBrakeEncoderProcessor.SetCommandLineArguments(new HandBrakeArguements()); }