aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Elmes <emms@repose.cx>2006-08-17 14:40:00 +0000
committerDamien Elmes <emms@repose.cx>2006-08-17 14:40:00 +0000
commitd3ff5574520143fdf7a00a0637d31f9ba5a3ded4 (patch)
treecfa3511f80909f4d2e37532bc01009d8bcbdaca8
parent293c5bc7c2208467f4297e3ff56707a031b56f38 (diff)
browser: add last-played support
You can now define filters to display only tracks played in the last week, month, etc. darcs-hash:20060817144049-4e3e3-e8f9ab27cf63a86ab6c0070fbee65c004cd08b28.gz
-rw-r--r--emms-browser.el16
1 files changed, 16 insertions, 0 deletions
diff --git a/emms-browser.el b/emms-browser.el
index 05c17f1..c32d49c 100644
--- a/emms-browser.el
+++ b/emms-browser.el
@@ -110,6 +110,10 @@
;; (emms-browser-make-filter
;; "80s" (emms-browser-filter-only-dir "~/Mp3s/80s"))
+;; ;; show all tracks played in the last month
+;; (emms-browser-make-filter
+;; "last-month" (emms-browser-filter-only-recent 30))
+
;; After executing the above commands, you can use M-x
;; emms-browser-show-all, emms-browser-show-80s, etc to toggle
;; between different collections. Alternatively you can use '<' and
@@ -1581,5 +1585,17 @@ If the track is not of TYPE, return t."
`(lambda (track)
(not (eq (quote ,type) (emms-track-get track 'type)))))
+;; seconds in a day (* 60 60 24) = 86400
+(defun emms-browser-filter-only-recent (days)
+ "Show only tracks played within the last number of DAYS."
+ `(lambda (track)
+ (let ((min-date (time-subtract
+ (current-time)
+ (seconds-to-time (* ,days 86400))))
+ last-played)
+ (not (and (setq last-played
+ (emms-track-get track 'last-played nil))
+ (time-less-p min-date last-played))))))
+
(provide 'emms-browser)
;;; emms-browser.el ends here