From d12e1dc2cfd8773c8c7bfb207e2fbcaad9d674a5 Mon Sep 17 00:00:00 2001 From: Rasmus Date: Tue, 29 Jul 2014 15:31:06 +0200 Subject: emms-info libtag.el: Easier to add new extension * emms-print-metadata.c (main): Better error message. * emms-info-libtag.el (emms-info-libtag): New group. (emms-info-libtag-program-name): Change to defcustom. (emms-info-libtag-known-extensions): New variable. (emms-info-libtag): Use emms-info-libtag-known-extensions. Two changes: First, emms-info-libtag tells the user that it may work with other forms. Since emms-info-libtag-known-extensions is now a regexp variable so users can easily add new extensions, if needed. --- lisp/emms-info-libtag.el | 42 ++++++++++++++++++++++++++++++++++++++---- src/emms-print-metadata.c | 2 +- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/lisp/emms-info-libtag.el b/lisp/emms-info-libtag.el index ae416ff..7954ab2 100644 --- a/lisp/emms-info-libtag.el +++ b/lisp/emms-info-libtag.el @@ -43,18 +43,52 @@ ;; (setq emms-info-functions '(emms-info-libtag)) +;; You may have to compile the program from source. +;; Make sure that you have libtag installed. +;; In the EMMS source directory do +;; +;; make emms-print-metadata +;; +;; and copy src/emms-print-metadata to your PATH. + +;; If compilation fails and libtag is installed, you may have to +;; change the line +;; +;; #include +;; +;; to the correction location, e.g. +;; +;; #include + ;;; Code: (require 'emms-info) +(defgroup emms-info-libtag nil + "Options for EMMS." + :group 'emms-info) + (defvar emms-info-libtag-coding-system 'utf-8) -(defvar emms-info-libtag-program-name "emms-print-metadata") + +(defcustom emms-info-libtag-program-name "emms-print-metadata" + "Name of emms-info-libtag program." + :type '(string) + :group 'emms-info-libtag) + +(defcustom emms-info-libtag-known-extensions + (regexp-opt '("mp3" "mp4" "m4a" "ogg" "flac" "spx" "wma")) + "Regexp of known extensions compatible with `emms-info-libtag-program-name'. + +Case is irrelevant." + :type '(string) + :group 'emms-info-libtag) (defun emms-info-libtag (track) (when (and (eq 'file (emms-track-type track)) - (string-match - "\\.\\([Mm][Pp][34]\\|[Mm]4[aA]\\|[oO][gG][gG]\\|[fF][lL][aA][cC]\\|[sS][pP][xX]\\)\\'" - (emms-track-name track))) + (let ((case-fold-search t)) + (string-match + emms-info-libtag-known-extensions + (emms-track-name track)))) (with-temp-buffer (when (zerop (let ((coding-system-for-read 'utf-8)) diff --git a/src/emms-print-metadata.c b/src/emms-print-metadata.c index d22fe96..48f4904 100644 --- a/src/emms-print-metadata.c +++ b/src/emms-print-metadata.c @@ -33,7 +33,7 @@ main (int argc, char **argv) if (argc != 2) { - fprintf (stderr, "usage: emms-print-metadata file.{mp3,ogg,flac}\n"); + fprintf (stderr, "usage: emms-print-metadata file.{mp3,ogg,flac}\nother formats may work as well.\n"); exit (1); } -- cgit v1.2.3