From 801ee6ec245a8a2fffdd81f256eab750634306fc Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 7 Feb 2022 17:09:32 -0600 Subject: Add +bongo-radio --- init.el | 67 +++++++++++++++++++++++++++++++++++++++++++++++--------- lisp/+bongo.el | 43 ++++++++++++++++++++++++++++++++++++ lisp/+tab-bar.el | 24 +++++++++++++++++--- 3 files changed, 121 insertions(+), 13 deletions(-) diff --git a/init.el b/init.el index a510daf..6fa9adc 100644 --- a/init.el +++ b/init.el @@ -792,22 +792,69 @@ They are completed by \"M-x TAB\" only in Tramp debug buffers." :host github :repo "dbrock/bongo")) (:also-load +bongo) - (:option bongo-default-directory "~/var/music") + (:option bongo-default-directory "~/var/music" + bongo-custom-backend-matchers '((mpv . (("https:") . t))) + +bongo-radio-stations ; use `+bongo-radio' for these + `(;; Local radio + ("KLSU" + . "http://130.39.238.143:8010/stream.mp3") + ("WRKF: NPR for the Capital Region" + . ,(concat "https://playerservices.streamtheworld.com/api/" + "livestream-redirect/WRKFFM.mp3")) + ("WRKF HD-2" + . ,(concat "https://playerservices.streamtheworld.com/api/" + "livestream-redirect/WRKFHD2.mp3")) + ("WBRH: Jazz & More" + . "http://wbrh.streamguys1.com/wbrh-mp3") + ("KBRH Blues & Rhythm Hits" + . "http://wbrh.streamguys1.com/kbrh-mp3") + ;; Soma FM + ("Soma FM Synphaera" + . "https://somafm.com/synphaera256.pls") + ("SomaFM BAGel Radio" + . "https://somafm.com/bagel.pls") + ("SomaFM Boot Liquor" + . "https://somafm.com/bootliquor320.pls") + ("SomaFM Deep Space One" + . "https://somafm.com/deepspaceone.pls") + ("SomaFM Fluid" + . "https://somafm.com/fluid.pls") + ("SomaFM Underground 80s" + . "https://somafm.com/u80s256.pls") + ;; Tildeverse & Friends + ("tilderadio" + . "https://azuracast.tilderadio.org/radio/8000/radio.ogg") + ("vantaradio" + . "https://vantaa.black/radio") + ;; Other online radio + ("BadRadio: 24/7 PHONK" + . "https://s2.radio.co/s2b2b68744/listen") + ("Cafe - lainon.life" + . "https://lainon.life/radio/cafe.ogg.m3u") + ("Everything - lainon.life" + . "https://lainon.life/radio/everything.ogg.m3u") + ("Swing - lainon.life" + . "https://lainon.life/radio/swing.ogg.m3u") + ("Cyberia - lainon.life" + . "https://lainon.life/radio/cyberia.ogg.m3u") + ("Nightwave Plaza - Online Vaporwave Radio" + . "http://radio.plaza.one/opus"))) + (advice-add 'bongo-play :before #'+bongo-stop-all) (with-eval-after-load 'notifications (add-hook 'bongo-player-metadata-changed-hook #'+bongo-notify))) (setup (:straight (cape :host github :repo "minad/cape")) (dolist (fn - ;; All available cape capfs listed here. Add them to the front since - ;; they're reversed with `add-to-list'. - '(cape-file - cape-dabbrev - cape-keyword - cape-abbrev - cape-ispell - ;;cape-dict - )) + ;; All available cape capfs listed here. Add them to the front since + ;; they're reversed with `add-to-list'. + '(cape-file + cape-dabbrev + cape-keyword + cape-abbrev + cape-ispell + ;;cape-dict + )) (add-to-list 'completion-at-point-functions fn :append))))) (setup (:straight circe) diff --git a/lisp/+bongo.el b/lisp/+bongo.el index d1a2ef4..da68024 100644 --- a/lisp/+bongo.el +++ b/lisp/+bongo.el @@ -4,6 +4,10 @@ ;;; Code: +(defgroup +bongo nil + "Extra customization for `bongo'." + :group 'bongo) + (defun +bongo-notify () (notifications-notify :title "Now Playing" @@ -13,5 +17,44 @@ :urgency 'low :transient t)) +(defun +bongo-stop-all () + "Ensure only one bongo playlist is playing at a time. +This is intended to be :before advice to `bongo-play'." + (mapc (lambda (b) + (with-current-buffer b + (when-let* ((modep (derived-mode-p + 'bongo-playlist-mode)) + (bongo-playlist-buffer b) + (playingp (bongo-playing-p))) + (bongo-stop)))) + (buffer-list))) + + +;;; Bongo Radio + +(defcustom +bongo-radio-stations nil + "Stations to play using `+bongo-radio'.") + +(defcustom +bongo-radio-buffer-name "*Bongo Radio*" + "Name of the buffer that holds all bongo radio stations." + :type 'string) + +(defun +bongo-radio () + (interactive) + (switch-to-buffer (or (get-buffer +bongo-radio-buffer-name) + (+bongo-radio-init)))) + +(defun +bongo-radio-init () + (interactive) + (let ((bongo-playlist-buffer (get-buffer-create +bongo-radio-buffer-name)) + (bongo-confirm-flush-playlist nil)) + (with-bongo-playlist-buffer + (bongo-playlist-mode) + (bongo-flush-playlist :delete-all) + (cl-loop for (name . url) in +bongo-radio-stations + do (bongo-insert-uri url name))) + (prog1 (switch-to-buffer bongo-playlist-buffer) + (goto-char (point-min))))) + (provide '+bongo) ;;; +bongo.el ends here diff --git a/lisp/+tab-bar.el b/lisp/+tab-bar.el index 6567f67..c5a93dc 100644 --- a/lisp/+tab-bar.el +++ b/lisp/+tab-bar.el @@ -65,8 +65,14 @@ (defun +tab-bar-bongo () "Display Bongo now playing information." - (when (and bongo-mode-line-indicator-mode - (bongo-playing-p)) + (when-let ((modep bongo-mode-line-indicator-mode) + (buf (cl-some (lambda (b) + (with-current-buffer b + (when-let* ((modep (derived-mode-p 'bongo-playlist-mode)) + (bongo-playlist-buffer b) + (playingp (bongo-playing-p))) + b))) + (buffer-list)))) `((bongo-now-playing menu-item ,(concat "{" (let ((bongo-field-separator "")) @@ -76,7 +82,19 @@ (bongo-formatted-infoset)) (- +tab-bar-emms-max-length 2))) "}") - bongo-pause/resume + (lambda () (interactive) + (let ((bongo-playlist-buffer + ;; XXX: I'm sure this is terribly inefficient + (cl-some (lambda (b) + (with-current-buffer b + (when-let* ((modep (derived-mode-p + 'bongo-playlist-mode)) + (bongo-playlist-buffer b) + (playingp (bongo-playing-p))) + b))) + (buffer-list)))) + (with-bongo-playlist-buffer + (bongo-pause/resume)))) :help ,(funcall bongo-header-line-function))))) (defvar +tab-bar-show-original nil -- cgit 1.4.1-21-gabe81