diff options
Diffstat (limited to 'emms.el')
-rw-r--r-- | emms.el | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -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) |