From e41edcad7947fab43b17cae064ae617d0162f783 Mon Sep 17 00:00:00 2001 From: forcer Date: Sat, 1 Apr 2006 18:59:00 +0000 Subject: Move emms-parse-playlist to emms-source-file.el, rename to emms-source-file-parse-playlist darcs-hash:20060401185913-2189f-75ccf31626867407f72de64642d6fc020cfc240e.gz --- emms-player-mpd.el | 3 ++- emms-source-file.el | 24 +++++++++++++++++++++++- emms.el | 23 ----------------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/emms-player-mpd.el b/emms-player-mpd.el index 176d50d..fe2bd33 100644 --- a/emms-player-mpd.el +++ b/emms-player-mpd.el @@ -90,6 +90,7 @@ ;; emms-playing-time, the displayed time will be accurate. (require 'emms-player-simple) +(require 'emms-source-file) ; for emms-source-file-parse-playlist (defun emms-player-mpd-get-supported-regexp () "Returns a regexp of file extensions that MusicPD supports, @@ -509,7 +510,7 @@ This handles both m3u and pls type playlists." ;; This allows us to keep playlists anywhere and not worry about ;; having to mangle their names. Also, mpd can't handle pls ;; playlists by itself. - (let ((playlist (emms-parse-playlist playlist)) + (let ((playlist (emms-source-file-parse-playlist playlist)) (any-success nil)) (dolist (file playlist) (when (emms-player-mpd-add-file file) diff --git a/emms-source-file.el b/emms-source-file.el index d3215a2..e2e1cec 100644 --- a/emms-source-file.el +++ b/emms-source-file.el @@ -149,11 +149,33 @@ or lines starting with '#'." emms-source-file-default-directory emms-source-file-default-directory t))) - (dolist (file (emms-parse-playlist playlist)) + (dolist (file (emms-source-file-parse-playlist playlist)) (if (string-match "\\`http://" file) (emms-source-url file) (emms-source-file file)))) +(defun emms-source-file-parse-playlist (playlist) + "Extract a list of filenames from the given .m3u or .pls playlist. +Empty lines and lines starting with '#' are ignored." + (let ((files '()) + (pls-p (if (string-match "\\.pls\\'" playlist) t nil)) + (dir (file-name-directory playlist))) + (with-temp-buffer + (insert-file-contents playlist) + (goto-char (point-min)) + (while (re-search-forward "^[^# ].*$" nil t) + (let ((line (match-string 0))) + (when pls-p + (if (string-match "\\`File[0-9]*=\\(.+\\)\\'" line) + (setq line (match-string 1 line)) + (setq line ""))) + (unless (string= line "") + (setq files (cons (if (or (string-match "\\`http://" line) + (file-name-absolute-p line)) + line + (concat dir line)) + files)))))) + (reverse files))) ;;; Helper functions diff --git a/emms.el b/emms.el index 8231074..51bab04 100644 --- a/emms.el +++ b/emms.el @@ -872,29 +872,6 @@ ignore this." (setq i (- i 1)))) vector) -(defun emms-parse-playlist (playlist) - "Extract a list of filenames from the given .m3u or .pls playlist. -Empty lines and lines starting with '#' are ignored." - (let ((files '()) - (pls-p (if (string-match "\\.pls\\'" playlist) t nil)) - (dir (file-name-directory playlist))) - (with-temp-buffer - (insert-file-contents playlist) - (goto-char (point-min)) - (while (re-search-forward "^[^# ].*$" nil t) - (let ((line (match-string 0))) - (when pls-p - (if (string-match "\\`File[0-9]*=\\(.+\\)\\'" line) - (setq line (match-string 1 line)) - (setq line ""))) - (unless (string= line "") - (setq files (cons (if (or (string-match "\\`http://" line) - (file-name-absolute-p line)) - line - (concat dir line)) - files)))))) - (reverse files))) - ;;; Saving playlists. (defun emms-playlist-save (playlist filename) -- cgit v1.2.3