Created
August 28, 2013 19:55
-
-
Save Darep/6370470 to your computer and use it in GitHub Desktop.
Clojure problem
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 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