diff options
author | Grant Shangreaux <grant@unabridgedsoftware.com> | 2021-01-10 20:30:35 -0600 |
---|---|---|
committer | Grant Shoshin Shangreaux <grant@churls.world> | 2021-05-07 16:02:25 -0500 |
commit | c80315946e885a523f74d6a66ca7d7fa0682d6c2 (patch) | |
tree | 7dcc9b0c6061e704e799f08e638cf9a5f2bbdc86 /emms-tracktag.el | |
parent | b0173b6b4c5b66a4706cb82c9b50a179bf159a0f (diff) |
Add: emms-tracktag wrapper for the audiotools program
http://audiotools.sourceforge.net/ provides a tool `tracktag`
which handles writing tags for several different audio formats,
including Opus. this patch provides a very basic wrapper to interface
between EMMS track info and tracktag metadata. It also configures
emms-tag-editor.el to use it for writing tags to Opus files.
Add: test.sh and test/test-all.el
Basic setup to run ert tests from the terminal using Emacs in batch
mode. This should load up only ERT, the tests in the test/ directory
and their dependencies.
Add: opus extension to emms-libtag-known-extensions
libtag works as a reader for opus files, this just ads the opus
extension to the regexp list.
Diffstat (limited to 'emms-tracktag.el')
-rw-r--r-- | emms-tracktag.el | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/emms-tracktag.el b/emms-tracktag.el new file mode 100644 index 0000000..0b8b660 --- /dev/null +++ b/emms-tracktag.el @@ -0,0 +1,71 @@ +;;; emms-tracktag.el --- EMMS interface for audiotools tracktag -*- lexical-binding: t; -*- + +;; Copyright (C) 2021 Grant Shoshin Shangreaux + +;; Author: Grant Shoshin Shangreaux <grant@churls.world> +;; Keywords: + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;; Provides a wrapper for audiotools tracktag executable +;; http://audiotools.sourceforge.net/tracktag.html +;; Given an EMMS TRACK structure, it will map the emms-info fields onto +;; arguments for tracktag. Then it calls the tracktag process to write the +;; info as metadata tags on the track's associated file. + +;;; Code: + +(require 'emms) + +(defvar emms-info-tracktag--info-fields + '((info-album . album) + (info-artist . artist) + (info-composer . composer) + (info-performer . performer) + (info-year . year) + (info-date . year) + (info-tracknumber . number) + (info-discnumber . album-number) + (info-note . comment) + (info-title . name)) + "An alist mapping info-* fields to tracktag fields.") + +(defun emms-tracktag--map-track-info (track) + (seq-filter (lambda (cell) (cdr cell)) + (mapcar (lambda (pair) + (cons (cdr pair) (emms-track-get track (car pair)))) + emms-info-tracktag--info-fields))) + +(defun emms-tracktag--build-args (track) + (flatten-list + (append (mapcar (lambda (pair) + (let ((tag (car pair)) (value (cdr pair))) + (when value + (if (string-equal value "") (concat "--remove-" (format "%s" tag)) + (concat "--" (format "%s" tag) "=" value))))) + (emms-tracktag--map-track-info track)) + (list (emms-track-name track))))) + +(defun emms-tracktag-file (track) + (apply #'call-process + "tracktag" nil + (get-buffer-create emms-tag-editor-log-buffer) + nil + "-Vdebug" + (emms-tracktag--build-args track))) + +(provide 'emms-tracktag) +;;; emms-tracktag.el ends here |