aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--emms-player-mpd.el21
-rw-r--r--emms-source-file.el27
-rw-r--r--emms.el23
-rw-r--r--emms.texinfo8
4 files changed, 42 insertions, 37 deletions
diff --git a/emms-player-mpd.el b/emms-player-mpd.el
index b0d0903..a5a38ea 100644
--- a/emms-player-mpd.el
+++ b/emms-player-mpd.el
@@ -387,21 +387,11 @@ This handles both m3u and pls type playlists."
;; This allows us to keep playlists anywhere and not worry about
;; having to mangle their names. Also, mpd can't handle pls
;; playlists by itself.
- (let ((pls-p (if (string-match "\\.pls\\'" playlist) t nil))
+ (let ((playlist (emms-parse-playlist playlist))
any-success)
- (mapc #'(lambda (file)
- (when pls-p
- (if (string-match "\\`File[0-9]*=\\(.*\\)\\'" file)
- (setq file (match-string 1 file))
- (setq file "")))
- (unless (or (string= file "")
- (string-match "\\`#" file))
- (when (emms-player-mpd-add-file file)
- (setq any-success t))))
- (split-string (with-temp-buffer
- (insert-file-contents playlist)
- (buffer-string))
- "\n"))
+ (dolist (file playlist)
+ (when (emms-player-mpd-add-file file)
+ (setq any-success t)))
any-success))
(defun emms-player-mpd-add (track)
@@ -501,7 +491,8 @@ info from MusicPD."
emms-player-mpd-music-directory
(setq file (emms-player-mpd-get-filename
(emms-track-name track)))
- (string-match emms-player-mpd-supported-regexp file))
+ (string-match emms-player-mpd-supported-regexp file)
+ (not (string-match "\\`http://" file)))
(setq info (emms-player-mpd-get-alist
(emms-player-mpd-parse-response
(emms-player-mpd-send-and-wait
diff --git a/emms-source-file.el b/emms-source-file.el
index f00ffe6..2da8d47 100644
--- a/emms-source-file.el
+++ b/emms-source-file.el
@@ -142,28 +142,19 @@ value of `emms-source-file-default-directory'."
;; FIXME! Does this work? -js
-;;;###autoload (autoload 'emms-play-m3u-playlist "emms-source-file" nil t)
-;;;###autoload (autoload 'emms-add-m3u-playlist "emms-source-file" nil t)
-(define-emms-source m3u-playlist (playlist)
- "A source for simple .m3u playlists. It ignores empty lines, or
-lines starting with '#'."
+;;;###autoload (autoload 'emms-play-playlist "emms-source-file" nil t)
+;;;###autoload (autoload 'emms-add-playlist "emms-source-file" nil t)
+(define-emms-source playlist (playlist)
+ "A source for .m3u and .pls playlists. It ignores empty lines,
+or lines starting with '#'."
(interactive (list (read-file-name "Play file: "
emms-source-file-default-directory
emms-source-file-default-directory
t)))
- (emms-source-files
- (let ((files '())
- (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)))
- (setq files (cons (if (file-name-absolute-p line)
- line
- (concat dir line))
- files)))))
- (reverse files))))
+ (dolist (file (emms-parse-playlist playlist))
+ (if (string-match "\\`http://" file)
+ (emms-source-url file)
+ (emms-source-file file))))
;;; Helper functions
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)
diff --git a/emms.texinfo b/emms.texinfo
index 0f5b69b..5a168f8 100644
--- a/emms.texinfo
+++ b/emms.texinfo
@@ -326,11 +326,11 @@ A source for an @var{url} - for example, for streaming.
@defun emms-add-url url
A source for an @var{url} - for example, for streaming.
@end defun
-@defun emms-play-m3u-playlist playlist
-A source for the M3u playlist format from the file @var{playlist}.
+@defun emms-play-playlist playlist
+A source for the M3u or PLS playlist format from the file @var{playlist}.
@end defun
-@defun emms-add-m3u-playlist playlist
-A source for the M3u playlist format from the file @var{playlist}.
+@defun emms-add-playlist playlist
+A source for the M3u or PLS playlist format from the file @var{playlist}.
@end defun
@defun emms-play-find dir regexp
A source that will find files in @var{dir} or