aboutsummaryrefslogtreecommitdiff
path: root/emms.el
diff options
context:
space:
mode:
Diffstat (limited to 'emms.el')
-rw-r--r--emms.el23
1 files changed, 23 insertions, 0 deletions
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)