From f27679b5e71c9abed75e662e2e0923fcb9ee3a66 Mon Sep 17 00:00:00 2001 From: Yoni Rabkin Date: Mon, 30 Jun 2014 14:34:41 -0400 Subject: * lisp/emms-player-mpd.el: Fix MPD listinfoall. Patch by Jose Antonio Ortega Ruiz . --- lisp/emms-player-mpd.el | 30 +++++++++++++++++++++++------- 1 file 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 +;; Author: Michael Olson , Jose Antonio Ortega Ruiz +;; ;; 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 () -- cgit v1.2.3