From 7dc68851d417343917f1c3d7eaaeef87b16b4690 Mon Sep 17 00:00:00 2001 From: Grant Shangreaux Date: Sun, 16 May 2021 17:45:40 -0500 Subject: Add: re-namespace emms-tag-tracktag, info-date map to date --- emms-tag-editor.el | 4 +-- emms-tag-tracktag.el | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++ emms-tracktag.el | 71 -------------------------------------------------- 3 files changed, 75 insertions(+), 73 deletions(-) create mode 100644 emms-tag-tracktag.el delete mode 100644 emms-tracktag.el diff --git a/emms-tag-editor.el b/emms-tag-editor.el index 45c90f7..ce9d934 100644 --- a/emms-tag-editor.el +++ b/emms-tag-editor.el @@ -37,7 +37,7 @@ (require 'emms-info-mp3info) (require 'emms-playlist-mode) (require 'emms-mark) -(require 'emms-tracktag) +(require 'emms-tag-tracktag) (require 'format-spec) (require 'subr-x) @@ -140,7 +140,7 @@ See also `emms-tag-editor-default-parser'.") (info-date . "--TDAT"))) ("ogg" . emms-tag-editor-tag-ogg) ("flac" . emms-tag-editor-tag-flac) - ("opus" . emms-tracktag-file)) + ("opus" . emms-tag-tracktag-file)) "An alist used when committing changes to tags in files. If the external program sets tags by command line options one-by-one, then the list should like: diff --git a/emms-tag-tracktag.el b/emms-tag-tracktag.el new file mode 100644 index 0000000..71c6ff5 --- /dev/null +++ b/emms-tag-tracktag.el @@ -0,0 +1,73 @@ +;;; emms-tag-tracktag.el --- EMMS interface for audiotools tracktag -*- lexical-binding: t; -*- + +;; Copyright (C) 2021 Grant Shoshin Shangreaux + +;; Author: Grant Shoshin Shangreaux +;; 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 . + +;;; 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-tag-tracktag--info-fields + '((info-artist . artist) + (info-composer . composer) + (info-performer . performer) + (info-title . name) + (info-album . album) + (info-tracknumber . number) + (info-discnumber . album-number) + (info-year . year) + (info-date . date) + (info-note . comment)) + "An alist mapping info-* fields to tracktag fields.") + +(defun emms-tag-tracktag--map-track-info (track) + (seq-filter (lambda (cell) (cdr cell)) + (mapcar (lambda (pair) + (cons (cdr pair) (emms-track-get track (car pair)))) + emms-tag-tracktag--info-fields))) + +(defun emms-tag-tracktag--build-args (track) + (flatten-list + (append + (mapcar (lambda (pair) + (let ((tag (car pair)) (value (cdr pair))) + (when value + ;; if we've deleted a tag value in the editor, remove the tag from file metadata. + (if (string-equal "" value) (concat "--remove-" (format "%s" tag)) + (concat "--" (format "%s" tag) "=" value))))) + (emms-tag-tracktag--map-track-info track)) + (list (emms-track-name track))))) + +(defun emms-tag-tracktag-file (track) + (apply #'call-process + "tracktag" nil + (get-buffer-create emms-tag-editor-log-buffer) + nil + "-Vdebug" + (emms-tag-tracktag--build-args track))) + +(provide 'emms-tag-tracktag) +;;; emms-tag-tracktag.el ends here diff --git a/emms-tracktag.el b/emms-tracktag.el deleted file mode 100644 index 0b8b660..0000000 --- a/emms-tracktag.el +++ /dev/null @@ -1,71 +0,0 @@ -;;; emms-tracktag.el --- EMMS interface for audiotools tracktag -*- lexical-binding: t; -*- - -;; Copyright (C) 2021 Grant Shoshin Shangreaux - -;; Author: Grant Shoshin Shangreaux -;; 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 . - -;;; 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 -- cgit v1.2.3