Created
March 3, 2012 22:03
-
-
Save telent/1968570 to your computer and use it in GitHub Desktop.
Audio (mp3/flac/etc) tag support for Clojure via JAudiotagger
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 characters
(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 characters
(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"]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The :tags map values are deliberately lists, because the spec apparently allows for multiple tags with the same name.