level 9
_湖心龙
楼主
好久没学了。这几天看了下书,自己写了个小程序,用来判断MP3文件用的是那种版本的ID3标签。
;;;;代码
(defun get-id3-ver(file-path)
(with-open-file (mp3-file file-path
:direction :input
:element-type '(unsigned-byte 8)
:if-does-not-exist nil)
(cond
((progn
(file-position mp3-file (- (file-length mp3-file) 128))
(and (char= #\T (code-char (read-byte mp3-file)))
(char= #\A (code-char (read-byte mp3-file)))
(char= #\G (code-char (read-byte mp3-file)))))
'id3-v1)
((progn
(file-position mp3-file 0)
(and (char= #\I (code-char (read-byte mp3-file)))
(char= #\D (code-char (read-byte mp3-file)))
(char= #\3 (code-char (read-byte mp3-file)))))
(let ((ver (read-byte mp3-file)))
(cond
((= ver 1) 'id3-v2.1)
((= ver 2) 'id3-v2.2)
((= ver 3) 'id3-v2.3)
((= ver 4) 'id3-v2.4)
((= ver 5) 'id3-v2.5)
(t 'other-version))))
(t 'other-version))))
2014年05月05日 18点05分
1
;;;;代码
(defun get-id3-ver(file-path)
(with-open-file (mp3-file file-path
:direction :input
:element-type '(unsigned-byte 8)
:if-does-not-exist nil)
(cond
((progn
(file-position mp3-file (- (file-length mp3-file) 128))
(and (char= #\T (code-char (read-byte mp3-file)))
(char= #\A (code-char (read-byte mp3-file)))
(char= #\G (code-char (read-byte mp3-file)))))
'id3-v1)
((progn
(file-position mp3-file 0)
(and (char= #\I (code-char (read-byte mp3-file)))
(char= #\D (code-char (read-byte mp3-file)))
(char= #\3 (code-char (read-byte mp3-file)))))
(let ((ver (read-byte mp3-file)))
(cond
((= ver 1) 'id3-v2.1)
((= ver 2) 'id3-v2.2)
((= ver 3) 'id3-v2.3)
((= ver 4) 'id3-v2.4)
((= ver 5) 'id3-v2.5)
(t 'other-version))))
(t 'other-version))))
