Skip to content

Instantly share code, notes, and snippets.

@amalloy

amalloy/tag.clj Secret

Created December 23, 2010 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amalloy/1f671546d31182bc746c to your computer and use it in GitHub Desktop.
Save amalloy/1f671546d31182bc746c to your computer and use it in GitHub Desktop.
(ns id3-tag-reader
(:import (java.io File RandomAccessFile)))
(defn has-id3-tag? [file-name]
"Returns t when the file has an id3 tag else nil"
(with-open [file (RandomAccessFile. (File. file-name) "r")]
(let [file-size (.length file)
[buffer (make-array Byte/TYPE 3)]]
(doto file
(.seek (- file-size 128))
(.read buffer 0 3))
(-> buffer
String.
(.equalsIgnoreCase "TAG")))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment