public void Parse(IEnumerable <string> args) { foreach (var arg in args) { if (arg.ToLower() == "--help" || arg.ToLower() == "-h") { OptHelp = true; continue; } if (arg.ToLower() == "--version") { OptVersion = true; continue; } if (arg.ToLower() == "--no-ffmpeg") { NoFFMPEG = false; continue; } if (arg.ToLower() == "--open-browser") { AutoOpenBrowser = true; continue; } if (arg.ToLower() == "--no-auto-previews") { AutoPreviewGen = false; continue; } if (arg.ToLower() == "--trim-info-json") { TrimDataJSON = true; continue; } if (!arg.StartsWith("--")) { continue; } var idx = arg.IndexOf("=", StringComparison.Ordinal); var key = arg.Substring(2, idx - 2).ToLower(); var value = arg.Substring(idx + 1); if (value.StartsWith("\"") && value.EndsWith("\"")) { value = value.Substring(1, value.Length - 2); } if (key == "display") { OptDisplayMode = int.Parse(value); } if (key == "order") { OptOrderMode = int.Parse(value); } if (key == "width") { OptWidthMode = int.Parse(value); } if (key == "thumbnailmode") { OptThumbnailMode = int.Parse(value); } if (key == "videomode") { OptVideoMode = int.Parse(value); } if (key == "path") { DataDirs.Add(DataDirSpec.Parse(value)); } if (key == "port") { Port = int.Parse(value); } if (key == "cache") { CacheDir = value; } if (key == "max-parallel-convert") { MaxParallelConvertJobs = int.Parse(value); } if (key == "max-parallel-genprev") { MaxParallelGenPreviewJobs = int.Parse(value); } if (key == "preview-width") { PreviewImageWidth = int.Parse(value); } if (key == "webm-convert-params") { ConvertFFMPEGParams = value; } if (key == "thumnail-ex-mode") { ThumbnailExtraction = (ThumbnailExtractionMode)int.Parse(value); } if (key == "previewcount-max") { MaxPreviewImageCount = int.Parse(value); } if (key == "previewcount-min") { MinPreviewImageCount = Math.Max(2, int.Parse(value)); } if (key == "ffmpeg-debug-dir") { FFMPEGDebugDir = value; } if (key == "exec-ffmpeg") { FFMPEGExec = value; } if (key == "exec-ffprobe") { FFPROBEExec = value; } if (key == "autorefresh-interval") { AutoRefreshInterval = int.Parse(value); } if (key == "cronrefresh-interval") { CronRefreshInterval = int.Parse(value); } if (key == "htmltitle") { HTMLTitle = value; } } if (!DataDirs.Any()) { DataDirs = new List <DataDirSpec> { DataDirSpec.FromPath(Environment.CurrentDirectory) } } ; if (Port == -1) { Port = FindFreePort(); } }
public static async Task <DataDirData> GetData(DataDirSpec spec) => await GetData(spec.Index);