about summary refs log tree commit homepage
path: root/lib/dtas/splitfx.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-01-24 03:52:34 +0000
committerEric Wong <e@80x24.org>2022-01-24 03:54:07 +0000
commit9183c38754d76fcd778965350046738557d13722 (patch)
tree52ce63b53f2640248755c6f55c1cba53a891d566 /lib/dtas/splitfx.rb
parentdf420d23dc7c53b808aa80210898265814671c7b (diff)
downloaddtas-9183c38754d76fcd778965350046738557d13722.tar.gz
This can allow filtering for tracks with a given comment
declared via the ".#{COMMENT}" mechanism or the track title.
If no prefix is given (before the '='), then all comment
values are matched.
Diffstat (limited to 'lib/dtas/splitfx.rb')
-rw-r--r--lib/dtas/splitfx.rb8
1 files changed, 8 insertions, 0 deletions
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]