Created
March 3, 2012 22:03
Revisions
-
telent created this gist
Mar 3, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ (ns onelouder.core (:import [org.jaudiotagger.audio AudioFileIO] [org.jaudiotagger.tag FieldKey])) (defn tags [file] (let [fields (apply conj {} (map (fn [n] [(keyword (. (. n toString) toLowerCase)) n]) (. FieldKey values))) tag (. file (getTag))] (apply conj {} (filter (fn [[name val]] (and val (not (empty? val)))) (map (fn [[name val]] [name (seq (map #(. % getContent) (. tag (getFields val))))]) fields))))) (defn audioheader [file] (bean (. file (getAudioHeader)))) (defn metadata [filename] (let [file (AudioFileIO/read (new java.io.File filename))] {:tags (tags file) :audioheader (audioheader file)})) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ (defproject onelouder "1.0.0-SNAPSHOT" :description "Audio (mp3/flac/etc) tag support for Clojure via JAudiotagger" :dependencies [[org.clojure/clojure "1.3.0"] [org/jaudiotagger "2.0.3"]])