From: Eric Wong <e@80x24.org>
To: dtas-all@nongnu.org
Subject: [PATCH 2/3] splitfx: add --filter option to limit match to comments
Date: Mon, 24 Jan 2022 11:35:49 +0000 [thread overview]
Message-ID: <20220124113550.19976-3-e@80x24.org> (raw)
In-Reply-To: <20220124113550.19976-1-e@80x24.org>
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.
---
bin/dtas-splitfx | 1 +
lib/dtas/splitfx.rb | 8 ++++++++
2 files changed, 9 insertions(+)
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 @@
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 @@ def run(target, opts = {})
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]
next prev parent reply other threads:[~2022-01-24 11:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-24 11:35 [PATCH 0/3] some splitfx-related enhancements Eric Wong
2022-01-24 11:35 ` [PATCH 1/3] splitfx: support per-track environment variables Eric Wong
2022-01-24 11:35 ` Eric Wong [this message]
2022-01-24 11:35 ` [PATCH 3/3] player: expire sox metadata cache on file st_ctime changes Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://80x24.org/dtas/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220124113550.19976-3-e@80x24.org \
--to=e@80x24.org \
--cc=dtas-all@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/dtas.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).