diff options
author | forcer <forcer> | 2006-04-01 18:59:00 +0000 |
---|---|---|
committer | forcer <mwolson@gnu.org> | 2006-04-01 18:59:00 +0000 |
commit | e41edcad7947fab43b17cae064ae617d0162f783 (patch) | |
tree | 21ecf5a20ea50a5af99ce21c6169ba5e0a0eefea /emms-source-file.el | |
parent | e539ab44dad0dfe282ef6cc4e30800cdbbb7be8d (diff) |
Move emms-parse-playlist to emms-source-file.el, rename to emms-source-file-parse-playlist
darcs-hash:20060401185913-2189f-75ccf31626867407f72de64642d6fc020cfc240e.gz
Diffstat (limited to 'emms-source-file.el')
-rw-r--r-- | emms-source-file.el | 24 |
1 files changed, 23 insertions, 1 deletions
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 |