From d3ff5574520143fdf7a00a0637d31f9ba5a3ded4 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 17 Aug 2006 14:40:00 +0000 Subject: 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 --- emms-browser.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 -- cgit v1.2.3