Stream ListenBrainz.org Music Playlist in GNU Emacs
Here's an Emacs Multimedia System (EMMS) extension for streaming ListenBrainz.org music playlist using mpv player (with ytdl support).
Irrespective of how satisfied you are with your music streaming service, you should plan for maintaining a playlist of your favorite music in an open format. The popular service might be forced to close down because of non-profitability even when you are willing to pay for ad-free music streaming. e.g. Worldspace radio customers even paid for the device in addition to the subscription fees.
"Process Tumblr's response in the current buffer,
returning JSON or signaling an error for other requests."
(decode-coding-region (point-min) (point-max) 'utf-8-dos)
;; the following copied from url.el
(goto-char (point-min))
(skip-chars-forward " \t\n") ; Skip any blank crap
(skip-chars-forward "HTTP/") ; Skip HTTP Version
(skip-chars-forward "[0-9].")
(let ((pointpos (point))
(code (read (current-buffer))))
(cond
((= code 100) ;; Gotta clean up the buffer and try again
(search-forward-regexp "^$" nil t)
(delete-region (point-min) (point))
(tumblesocks-api-process-response))
((not (and (<= 200 code) (<= code 299)))
(if (= code 401)
(setq tumblesocks-token
(delq (assoc service tumblesocks-token) tumblesocks-token)))
(error (buffer-substring pointpos
(line-end-position))))
(t
(search-forward-regexp "^$" nil t)
;; body
(let* ((json-response (buffer-substring (1+ (point)) (point-max)))
(json-object-type 'plist)
(json-array-type 'list)
(json-false nil))
;; (plist-get (json-read-from-string json-response)
;; :response)
(json-parse-string json-response)
)))))
Usage
You'll need mpv and ytdl installed. Configure emms as follows:
(setq emms-player-list '(emms-player-mpv))
You'll need an API token from Listenbrainz for using the service. You can get it here.
Use M-x emms-listenbrainz to create a playlist buffer for Listenbrainz. Then you can use emms smart playlist keybindings for interaction with the playlist.
Tag Editor
Code
Comments
Post a Comment