about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rwxr-xr-xbin/dtas-splitfx1
-rw-r--r--lib/dtas/splitfx.rb8
2 files changed, 9 insertions, 0 deletions
diff --git a/bin/dtas-splitfx b/bin/dtas-splitfx
index 6ce6521..d0afc7b 100755
--- a/bin/dtas-splitfx
+++ b/bin/dtas-splitfx
@@ -13,6 +13,7 @@ OptionParser.new('', 24, '  ') do |op|
   op.on('-n', '--dry-run') { opts[:dryrun] = true }
   op.on('-j', '--jobs [JOBS]', Integer) { |val| opts[:jobs] = val } # nil==inf
   op.on('-s', '--quiet', '--silent') { opts[:silent] = true }
+  op.on('-f', '--filter FILTER') { |val| (opts[:filter] ||= []) << val }
   op.on('-D', '--no-dither') { opts[:no_dither] = true }
   op.on('-O', '--outdir OUTDIR') { |val| opts[:outdir] = val }
   op.on('-C', '--compression FACTOR') { |val| opts[:compression] = val }
diff --git a/lib/dtas/splitfx.rb b/lib/dtas/splitfx.rb
index 1ce2007..696b9ce 100644
--- a/lib/dtas/splitfx.rb
+++ b/lib/dtas/splitfx.rb
@@ -360,6 +360,14 @@ class DTAS::SplitFX # :nodoc:
 
     fails = []
     tracks = @tracks.dup
+    (opts[:filter] || []).each do |re|
+      field, val = re.split(/=/, 2)
+      if val
+        tracks.delete_if { |t| (t.comments[field] || '') !~ /#{val}/ }
+      else
+        tracks.delete_if { |t| t.comments.values.grep(/#{re}/).empty? }
+      end
+    end
     pids = {}
     jobs = opts[:jobs] || tracks.size # jobs == nil => everything at once
     if opts[:sox_pipe]