From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 453801F852 for ; Mon, 24 Jan 2022 11:36:04 +0000 (UTC) Received: from localhost ([::1]:54298 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nBxdj-0003H1-GB for e@80x24.org; Mon, 24 Jan 2022 06:36:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBxdi-0003GI-Br for dtas-all@nongnu.org; Mon, 24 Jan 2022 06:36:02 -0500 Received: from dcvr.yhbt.net ([64.71.152.64]:33494) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBxdg-0002rN-T5 for dtas-all@nongnu.org; Mon, 24 Jan 2022 06:36:02 -0500 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 7267B1F9FC for ; Mon, 24 Jan 2022 11:35:50 +0000 (UTC) From: Eric Wong 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 Message-Id: <20220124113550.19976-3-e@80x24.org> In-Reply-To: <20220124113550.19976-1-e@80x24.org> References: <20220124113550.19976-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=64.71.152.64; envelope-from=e@80x24.org; helo=dcvr.yhbt.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: dtas-all@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: duct tape audio suite List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dtas-all-bounces+e=80x24.org@nongnu.org Sender: "dtas-all" 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]