-
-
Save amalloy/1f671546d31182bc746c to your computer and use it in GitHub Desktop.
This file contains 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 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