diff options
author | Yoni Rabkin <yonirabkin@member.fsf.org> | 2014-06-30 14:34:41 -0400 |
---|---|---|
committer | Yoni Rabkin <yonirabkin@member.fsf.org> | 2014-06-30 14:34:41 -0400 |
commit | f27679b5e71c9abed75e662e2e0923fcb9ee3a66 (patch) | |
tree | ba3c8ee128291538f205b7f59d48bb3e604afb29 | |
parent | 6b58bd4167e232cdaaf032c0959e4b1c43b21e9c (diff) |
* lisp/emms-player-mpd.el: Fix MPD listinfoall.
Patch by Jose Antonio Ortega Ruiz <jao@gnu.org>.
-rw-r--r-- | lisp/emms-player-mpd.el | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/lisp/emms-player-mpd.el b/lisp/emms-player-mpd.el index 332cb51..3a4ae3d 100644 --- a/lisp/emms-player-mpd.el +++ b/lisp/emms-player-mpd.el @@ -1,8 +1,9 @@ ;;; emms-player-mpd.el --- MusicPD support for EMMS -;; Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2014 Free Software Foundation, Inc. -;; Author: Michael Olson <mwolson@gnu.org> +;; Author: Michael Olson <mwolson@gnu.org>, Jose Antonio Ortega Ruiz +;; <jao@gnu.org> ;; This file is part of EMMS. @@ -1188,6 +1189,14 @@ The track should be an alist as per `emms-player-mpd-get-alist'." (emms-info-mpd-process track track-info) (funcall emms-cache-set-function 'file name track))))) +(defun emms-cache--info-cleanup (info) + (let ((xs (mapcar (lambda (x) + (and (stringp x) + (not (string-match-p "\\`\\(Last-\\|direct\\)" x)) + x)) + info))) + (cons nil (delq nil xs)))) + (defun emms-cache-set-from-mpd-directory (dir) "Dump all MusicPD data from DIR into the EMMS cache. @@ -1207,11 +1216,18 @@ This is useful to do when you have recently acquired new music." nil (lambda (closure response) (message "Dumping MusicPD data to cache...processing") - (let ((info (emms-player-mpd-get-alists - (emms-player-mpd-parse-response response)))) - (dolist (track-info info) - (emms-cache-set-from-mpd-track track-info)) - (message "Dumping MusicPD data to cache...done"))))) + (let ((info (emms-player-mpd-parse-response response))) + (when (null (car info)) + (let* ((info (emms-cache--info-cleanup info)) + (info (emms-player-mpd-get-alists info)) + (track 1) + (total (length info))) + (dolist (track-info info) + (message "Dumping MusicPD data to cache...%d/%d" track total) + (emms-cache-set-from-mpd-track track-info) + (setq track (+ 1 track))) + (message "Dumping MusicPD data to cache... %d tracks processed" + total))))))) (error "Caching is not enabled"))) (defun emms-cache-set-from-mpd-all () |