Hi,

The following patch makes some small changes to emms-info-libtag.el to
make it easier to customize.  For instance, libtag handles wma files!
I also added another line to the c-program stderr.

One thing that might be worth considering is whether
`emms-info-libtag-known-extensions' should be a list rather than a
string.  The regexp could then be computed.

Also, I did not get emms-print-metadata with my melpa package — not
even the source.  I did not check if it's included with the ELPA
package since it is v3.

Cheers,
Rasmus

-- 
. . . The proofs are technical in nature and provides no real understanding
>From 26f32c4d77bd3046e7f8c0eb06a0ecd3d17a3ade Mon Sep 17 00:00:00 2001
From: Rasmus <[email protected]>
Date: Tue, 29 Jul 2014 15:31:06 +0200
Subject: [PATCH] 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 <tag_c.h>
+;;
+;; to the correction location, e.g.
+;;
+;;    #include <taglib/tag_c.h>
+
 ;;; 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 d04e759..10aca47 100644
--- a/src/emms-print-metadata.c
+++ b/src/emms-print-metadata.c
@@ -32,7 +32,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);
     }
 
-- 
2.0.3

_______________________________________________
Emms-help mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/emms-help

Reply via email to