Source

cl-taglib / cl-taglib.lisp

Diff from to

File cl-taglib.lisp

 	      `(defun ,function-name (tag)
 		(foreign-funcall ,foreign-name :pointer tag ,type)))
 	  `(defun (setf ,function-name) (value tag)
-	    (foreign-funcall ,foreign-set-name :pointer tag ,type value :void)))))
-
-(tag-accessor-for :title :string)
-(tag-accessor-for :artist :string)
-(tag-accessor-for :album :string)
-(tag-accessor-for :comment :string)
-(tag-accessor-for :genre :string)
-(tag-accessor-for :year :uint)
-(tag-accessor-for :track :uint)
+	    (foreign-funcall ,foreign-set-name :pointer tag ,type value :void))
+	  `(list ,slot ',function-name))))
+
+(defparameter *tag-accessors* (list (tag-accessor-for :title :string)
+				    (tag-accessor-for :artist :string)
+				    (tag-accessor-for :album :string)
+				    (tag-accessor-for :comment :string)
+				    (tag-accessor-for :genre :string)
+				    (tag-accessor-for :year :uint)
+				    (tag-accessor-for :track :uint)))
+
+(defun extract-tags (pathname)
+  (with-tag-file (file pathname)
+    (let ((tag (file-tag file))
+	  (result ()))
+      (dolist (accessor *tag-accessors* result)
+	(push (funcall (cadr accessor) tag) result)
+	(push (car accessor) result)))))
 
 (defmacro audio-reader-for (slot)
   (let ((function-name (intern (concatenate 'string "AUDIO-" (string slot))))