From b215622aad016d7e39fda64809579bf2be0d3783 Mon Sep 17 00:00:00 2001 From: Michael Olson Date: Sat, 7 Jan 2006 05:33:00 +0000 Subject: Rename m3u-playlist source to "playlist" and support .pls files. The playlist-parsing routine has been moved to a separate function, since the MusicPD player also needs to use it. Detect URLs in playlists and use type of 'url when creating tracks for them. darcs-hash:20060107053310-1bfb2-dc5bf155e440294ee4a91b08033fa4b4242695ab.gz --- emms.el | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'emms.el') diff --git a/emms.el b/emms.el index e547348..5d3e656 100644 --- a/emms.el +++ b/emms.el @@ -866,6 +866,29 @@ 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