static int Main(string[] args) { Mapper.Initialize(cfg => cfg.AddProfile <OSDbProfile>()); client = new OSDbClient(OSDbClient.DefaultUserAgent); options = new SubtleOptions(); CommandLine.Parser.Default.ParseArgumentsStrict(args, options); if (string.IsNullOrEmpty(options.Path)) { Console.WriteLine("Missing path."); Console.WriteLine(options.GetUsage()); return(1); } language = OSDbConfig.Languages.SingleOrDefault(l => options.Language.Equals(l.Iso6391, StringComparison.OrdinalIgnoreCase) || options.Language.Equals(l.Iso6392, StringComparison.OrdinalIgnoreCase)); if (language == null) { Console.WriteLine("Unrecognized language code."); Console.WriteLine(options.GetUsage()); return(1); } return(MainAsync().GetAwaiter().GetResult()); }
static int Main(string[] args) { Mapper.Initialize(cfg => cfg.AddProfile<OSDbProfile>()); client = new OSDbClient(OSDbClient.DefaultUserAgent); options = new SubtleOptions(); CommandLine.Parser.Default.ParseArgumentsStrict(args, options); if (string.IsNullOrEmpty(options.Path)) { Console.WriteLine("Missing path."); Console.WriteLine(options.GetUsage()); return 1; } language = OSDbConfig.Languages.SingleOrDefault(l => options.Language.Equals(l.Iso6391, StringComparison.OrdinalIgnoreCase) || options.Language.Equals(l.Iso6392, StringComparison.OrdinalIgnoreCase)); if (language == null) { Console.WriteLine("Unrecognized language code."); Console.WriteLine(options.GetUsage()); return 1; } return MainAsync().GetAwaiter().GetResult(); }
static void Main(string[] args) { client = new OSDbClient(OSDbClient.DefaultUserAgent); options = new SubtleOptions(); CommandLine.Parser.Default.ParseArgumentsStrict(args, options); if (string.IsNullOrEmpty(options.Path)) { Console.WriteLine("Missing path."); Console.WriteLine(options.GetUsage()); Environment.Exit(1); } language = OSDbConfig.Languages.SingleOrDefault(l => options.Language.Equals(l.Iso6391, StringComparison.OrdinalIgnoreCase) || options.Language.Equals(l.Iso6392, StringComparison.OrdinalIgnoreCase)); if (language == null) { Console.WriteLine("Unrecognized language code."); Console.WriteLine(options.GetUsage()); Environment.Exit(1); } if (Directory.Exists(options.Path)) { client.InitSession(); var results = ScanDirectory(options.Path) .Select(SearchSubtitle) .Where(s => s.Selection != null) .ToList(); if (!options.DryRun) { Console.WriteLine(); DownloadSubtitles(results); } } else if (File.Exists(options.Path)) { client.InitSession(); var sub = SearchSubtitle(options.Path); if (sub.Selection != null && !options.DryRun) { DownloadSubtitle(sub); } } else { Console.WriteLine("Path must be an existing file or directory."); Console.WriteLine(options.GetUsage()); Environment.Exit(1); } }