 (ns mdr2.dtb
   "Functions to query DAISY Talking Books"
   (:require [clojure.data.xml :as xml]
-            [clojure.java.io :refer [file]])
+            [clojure.java.io :refer [file]]
+            [clojure.java.shell :refer [sh]]
+            [clojure.string :refer [trim-newline]])
   (:import javax.sound.sampled.AudioSystem))
 
 (defn file-audio-length

        durationInSeconds (/ frames frameRate)]
    durationInSeconds))

(defn wav-file? [file]
  (and (.isFile file)
       (.endsWith (.getName file) ".wav")))

(defn audio-length [dtb]
  (let [audio-files (filter wav-file? (file-seq (file dtb)))]
    (reduce + (map file-audio-length audio-files))))
