aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlucas <lucas>2005-09-12 17:23:00 +0000
committerlucas <mwolson@gnu.org>2005-09-12 17:23:00 +0000
commit4ab7c61701b9eb1bac0d75207fdcf8bbe17dbec2 (patch)
treeeb4da71a48a3ec53c5aebbb52414d7800b015887
parent731479aad60f6d75e3371503b3ccc0c29496dbd6 (diff)
First attempt at reading playing time for .ogg
Problem : it's a bit long to read the info now. We need to optimize that. darcs-hash:20050912172312-4f952-73cffb3445ed251fd8cb7e5d691f7c95a676bda0.gz
-rw-r--r--emms-info-ogg.el21
1 files changed, 18 insertions, 3 deletions
diff --git a/emms-info-ogg.el b/emms-info-ogg.el
index b284df6..ca3059f 100644
--- a/emms-info-ogg.el
+++ b/emms-info-ogg.el
@@ -56,25 +56,40 @@ ogg-comments.el"
(defun emms-info-ogg-comment-providep (track)
"Return non-nil if this info-method provides info for the track."
(if (and track (emms-track-name track)
- (string-match "\\.ogg$" (emms-track-name track)))
+ (string-match "\\.ogg$" (emms-track-name track)))
t
nil))
(defun emms-info-ogg-get-comment (field info)
(let ((comment (cadr (assoc field (cadr info)))))
(if comment
- comment
+ comment
"")))
+
(defun emms-info-ogg-comment-get (track)
"Retrieve an emms-info strucutre as an ogg-comment"
- (let ((info (oggc-read-header (emms-track-name track))))
+ (let ((info (oggc-read-header (emms-track-name track)))
+ (file (emms-track-get track 'name)))
+ (with-temp-buffer
+ (call-process "ogginfo" nil t nil file)
+ (goto-char (point-min))
+ (re-search-forward "Playback length: \\([0-9]*\\)m:\\([0-9]*\\)")
+ (let ((minutes (string-to-int (match-string 1)))
+ (seconds (string-to-int (match-string 2))))
+ (setq ptime-total (+ (* minutes 60) seconds)
+ ptime-min minutes
+ ptime-sec seconds)))
+
(make-emms-info :title (emms-info-ogg-get-comment "title" info)
:artist (emms-info-ogg-get-comment "artist" info)
:album (emms-info-ogg-get-comment "album" info)
:note (emms-info-ogg-get-comment "comment" info)
:year (emms-info-ogg-get-comment "date" info)
:genre (emms-info-ogg-get-comment "genre" info)
+ :playing-time ptime-total
+ :playing-time-min ptime-min
+ :playing-time-sec ptime-sec
:file (emms-track-name track))))
(provide 'emms-info-ogg)