public TestCacheFixture() { this.JavaClientCache = new JavaClientCache("testcache/java", false); this.Caches[typeof(JavaClientCache)] = this.JavaClientCache; this.NxtClientCache = new NxtClientCache("testcache/nxt", false); this.Caches[typeof(NxtClientCache)] = this.NxtClientCache; this.DownloaderCache = new DownloaderCache(); this.Caches[typeof(DownloaderCache)] = this.DownloaderCache; this.FlatFileCache = new FlatFileCache("testcache/file"); this.Caches[typeof(FlatFileCache)] = this.FlatFileCache; this.SoundtrackExtractor = new SoundtrackExtractor(this.JavaClientCache, "soundtrack"); }
public override int Run() { using var sourceCache = this.ArgumentParser.SourceCache; if (sourceCache == null) { Console.WriteLine("No cache source specified."); return(Program.ExitCodeInvalidArgument); } var soundtrackExtractor = new SoundtrackExtractor( sourceCache, this.ArgumentParser.OutputDirectory ?? "audio" ); if (this._scrapeFiles == null) { soundtrackExtractor.ExtractSoundtrack( this._overwrite, this._lossless, this._includeUnnamed, this._trackNameFilters, AudioCommand.Parallelism ); Console.WriteLine("Done combining soundtracks."); return(Program.ExitCodeOk); } if (this._scrapeFiles.Item1.Length == 0) { Console.WriteLine("No files to scrape specified."); return(Program.ExitCodeInvalidArgument); } foreach (var index in this._scrapeFiles.Item1) { var fileIds = this._scrapeFiles.Item2.Length > 0 ? this._scrapeFiles.Item2 : sourceCache.GetAvailableFileIds(index); Parallel.ForEach( fileIds, new ParallelOptions { MaxDegreeOfParallelism = AudioCommand.Parallelism, }, fileId => { try { var file = sourceCache.GetFile(index, fileId); soundtrackExtractor.ExtractIfJagaFile(file, $"{(int)index}-{fileId}", this._overwrite, this._lossless); } catch (SoundtrackException exception) { if (!exception.IsSoxError) { throw; } Log.Information($"Failed to combine {(int)index}/{fileId}: {exception.Message}"); } } ); } Console.WriteLine("Done scraping audio."); return(Program.ExitCodeOk); }