aboutsummaryrefslogtreecommitdiff
path: root/emms.el
diff options
context:
space:
mode:
authorMichael Olson <mwolson@gnu.org>2006-01-07 05:33:00 +0000
committerMichael Olson <mwolson@gnu.org>2006-01-07 05:33:00 +0000
commitb215622aad016d7e39fda64809579bf2be0d3783 (patch)
tree386d95d996ada4725b1771f0ee3caaccea798415 /emms.el
parent65dc3b56ef44b83fcb4f87cf8bf397fe0a8402e8 (diff)
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
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)