.emacs.d/site-lisp/metalexpress.el

This commit is contained in:
Tom Willemsen 2012-12-04 17:44:57 +01:00
parent ff77b0c0d9
commit 272c8f7238

View file

@ -30,12 +30,32 @@
(defcustom metal-express-radio-playlist-url (defcustom metal-express-radio-playlist-url
"http://usa7-vn.mixstream.net/listen/8248.m3u" "http://usa7-vn.mixstream.net/listen/8248.m3u"
"The URL of the Metal Express Radio stream.") "The URL of the Metal Express Radio stream."
:group 'metal-express-radio
:type 'string)
(defcustom metal-express-radio-song-changed-hook nil
"Hook run when the currently playing song changes."
:type 'hook
:group 'metal-express-radio)
(defvar metal-express-radio-currently-playing nil
"The currently playing song.")
(defun mer-proc-filter (proc string) (defun mer-proc-filter (proc string)
(when (string-match "^ICY Info: StreamTitle='\\(.*\\)';StreamUrl='';" (when (string-match "^ICY Info: StreamTitle='\\(.*\\)';StreamUrl='';"
string) string)
(message (match-string 1 string)))) (setq metal-express-radio-currently-playing (match-string 1 string))
(apply 'run-hooks metal-express-radio-song-changed-hook)))
(defun metal-express-radio-echo-currently-playing ()
(interactive)
(message metal-express-radio-currently-playing))
(defun metal-express-radio-notify ()
(interactive)
(notifications-notify :title "Now playing:"
:body metal-express-radio-currently-playing))
;;;###autoload ;;;###autoload
(defun metal-express-radio-start () (defun metal-express-radio-start ()
@ -50,5 +70,10 @@
(interactive) (interactive)
(kill-process (get-buffer-process "*Metal Express Radio*"))) (kill-process (get-buffer-process "*Metal Express Radio*")))
(add-hook 'metal-express-radio-song-changed-hook
'metal-express-radio-echo-currently-playing)
(add-hook 'metal-express-radio-song-changed-hook
'metal-express-radio-notify)
(provide 'metalexpress) (provide 'metalexpress)
;;; metalexpress.el ends here ;;; metalexpress.el ends here