All Operations are in expected output order. I can *see* the pattern; I just can't yet rationalize it the way I want.

This commit is contained in:
Elf M. Sternberg 2014-12-08 21:21:51 -08:00
parent 080842033a
commit 47f3b2531a
1 changed files with 13 additions and 15 deletions

View File

@ -136,29 +136,27 @@
(cond [(.has_key opts "usefilename") (fn [tag file] (title-strategy file))] (cond [(.has_key opts "usefilename") (fn [tag file] (title-strategy file))]
[true (fn [tag file] (or tag (title-strategy file)))])) [true (fn [tag file] (or tag (title-strategy file)))]))
; Given a list of mp3s, derive the list of ID3 tags. Obviously, ; Given a list of mp3s, derive the list of ID3 tags. Obviously,
; filesystem access is a point of failure, but this is mostly ; filesystem access is a point of failure, but this is mostly
; reliable. ; reliable.
(defn fetch-tags [mp3s] (defn fetch-tags [filenames]
(defn fetch-tag [pos mp3] (defn fetch-tag [pos filename]
(try (try
(let [[tag (.Tag eyeD3)]] (let [[tag (.Tag eyeD3)]]
(tag.link mp3) (tag.link filename)
(, mp3 (str (.getArtist tag)) (str (.getAlbum tag)) (, pos (str (.getArtist tag)) (str (.getAlbum tag))
(str (.getGenre tag)) (str (.getTitle tag)) pos)) (str (.getGenre tag)) (str (.getTitle tag)) filename))
(catch [err Exception] (catch [err Exception]
(, mp3 "" "" "" "" 1)))) (, filename "" "" "" "" 1))))
(ap-map (apply fetch-tag it) mp3s)) (ap-map (apply fetch-tag it) filenames))
(defn derive-tags [filenames artist-deriver album-deriver genre-deriver title-deriver]
(defn derive-tags [mp3s artist-deriver album-deriver genre-deriver title-deriver] (defn derive-tag [filename]
(defn derive-tag [mp3] (let [[file (get filename 0)]]
(let [[file (get mp3 0)]] (, (get filename 0) (artist-deriver (get filename 1) file) (album-deriver (get filename 2) file)
(, (get mp3 5) (artist-deriver (get mp3 1) file) (album-deriver (get mp3 2) file) (genre-deriver (get filename 3) file) (title-deriver (get filename 4) file) (get filename 5))))
(genre-deriver (get mp3 3) file) (title-deriver (get mp3 4) file) (get mp3 0)))) (ap-map (derive-tag it) filenames))
(ap-map (derive-tag it) mp3s))
; For all the songs, analyze a consist entry (usually genre and album ; For all the songs, analyze a consist entry (usually genre and album
; names), and return the one with the most votes. ; names), and return the one with the most votes.