Skip to content

Instantly share code, notes, and snippets.

@Darep
Created August 28, 2013 19:55
Show Gist options
  • Save Darep/6370470 to your computer and use it in GitHub Desktop.
Save Darep/6370470 to your computer and use it in GitHub Desktop.
Clojure problem
(ns beatstream.songs
(:require clojure.java.io)
(:import [org.jaudiotagger.audio AudioFileIO]
[org.jaudiotagger.tag FieldKey]))
(def music-path "/Users/ajk/Music/")
(defn get-song-files [directory]
(->> directory
clojure.java.io/file
file-seq
(filter #(.isFile %))
(filter #(re-find #"(?i)\.(mp3|ogg)$" (.getAbsolutePath %)))))
(defn update-medialibrary []
"TODO: read ID3, add file to database with ID3 info"
"artist, album, title, album artist, tracknumber, title, duration, year, genre, file path"
(doseq [f (get-song-files music-path)]
(println (.getFirst (.getTag (AudioFileIO/read f)) FieldKey/ARTIST))))
;; How can I create a data structure like this:
;;
;; {:artist "AC/DC"
;; :album "Back In black"
;; :title "Shoot to Thrill"
;; :tracknumber 2
;; :duration 317}
;;
;; Healp. I wanna save this to the database using 'korma'.
;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment