| 1 | ;; emms-streams.el -- A collection of online streaming audio -*- lexical-binding: t; -*- |
| 2 | |
| 3 | ;; Copyright (C) 2019, 2022 Free Software Foundation, Inc. |
| 4 | |
| 5 | ;; Authors: Yoni Rabkin <yrk@gnu.org> |
| 6 | |
| 7 | ;; This file is part of EMMS. |
| 8 | |
| 9 | ;; EMMS is free software; you can redistribute it and/or modify it |
| 10 | ;; under the terms of the GNU General Public License as published by |
| 11 | ;; the Free Software Foundation; either version 3 of the License, or |
| 12 | ;; (at your option) any later version. |
| 13 | |
| 14 | ;; EMMS is distributed in the hope that it will be useful, but WITHOUT |
| 15 | ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 16 | ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public |
| 17 | ;; License for more details. |
| 18 | |
| 19 | ;; You should have received a copy of the GNU General Public License |
| 20 | ;; along with EMMS; if not, write to the Free Software Foundation, |
| 21 | ;; Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. |
| 22 | |
| 23 | ;;; Commentary: |
| 24 | |
| 25 | ;; 2019-11-05 - This is a complete re-write of the emms-streams.el, |
| 26 | ;; using a different approach. |
| 27 | |
| 28 | ;; This includes the built-in list of streams which come with Emms by |
| 29 | ;; default. Emms has no affiliation of any kind with the streaming |
| 30 | ;; audio stations listed below, nor is this an endorsement of these |
| 31 | ;; stations. Instead, this is a collection of stations submitted to |
| 32 | ;; the project over the years by people who enjoy Emms. We hope you |
| 33 | ;; will enjoy them too. |
| 34 | |
| 35 | ;;; Code: |
| 36 | |
| 37 | (require 'emms) |
| 38 | (require 'emms-source-playlist) |
| 39 | (require 'emms-playlist-mode) |
| 40 | (require 'emms-cache) |
| 41 | |
| 42 | |
| 43 | ;;; ------------------------------------------------------------------ |
| 44 | ;;; definitions |
| 45 | ;;; ------------------------------------------------------------------ |
| 46 | |
| 47 | (defvar emms-streams-buffer-name "Emms Streams" |
| 48 | "Name for creating a streams buffer.") |
| 49 | |
| 50 | (defvar emms-streams-built-in-disclaimer |
| 51 | ";; This includes the built-in list of streams which come with Emms by |
| 52 | ;; default. Emms has no affiliation of any kind with the streaming |
| 53 | ;; audio stations listed below, nor is this an endorsement of these |
| 54 | ;; stations. Instead, this is a collection of stations submitted to |
| 55 | ;; the project over the years by people who enjoy Emms. We hope you |
| 56 | ;; will enjoy them too." |
| 57 | "Explaining the relationship between Emms and these streams.") |
| 58 | |
| 59 | (defvar emms-streams-built-in-list |
| 60 | '((*track* (type . streamlist) |
| 61 | (name . "http://www.somafm.com/beatblender.pls") |
| 62 | (metadata "SomaFM: Beatblender" "http://www.somafm.com/beatblender.pls" 1 streamlist)) |
| 63 | (*track* (type . streamlist) |
| 64 | (name . "http://www.somafm.com/secretagent.pls") |
| 65 | (metadata "SomaFM: Secret Agent" "http://www.somafm.com/secretagent.pls" 1 streamlist)) |
| 66 | (*track* (type . streamlist) |
| 67 | (name . "http://www.somafm.com/groovesalad.pls") |
| 68 | (metadata "SomaFM: Groove Salad" "http://www.somafm.com/groovesalad.pls" 1 streamlist)) |
| 69 | (*track* (type . streamlist) |
| 70 | (name . "http://www.somafm.com/dronezone.pls") |
| 71 | (metadata "SomaFM: Drone Zone" "http://www.somafm.com/dronezone.pls" 1 streamlist)) |
| 72 | (*track* (type . streamlist) |
| 73 | (name . "http://www.somafm.com/thetrip.pls") |
| 74 | (metadata "SomaFM: The Trip" "http://www.somafm.com/thetrip.pls" 1 streamlist)) |
| 75 | (*track* (type . streamlist) |
| 76 | (name . "http://www.somafm.com/indiepop.pls") |
| 77 | (metadata "SomaFM: Indie Pop Rocks" "http://www.somafm.com/indiepop.pls" 1 streamlist)) |
| 78 | (*track* (type . url) (name . "http://listen.radionomy.com:80/-PHILOSOMATIKAPROGRESSIVE-") |
| 79 | (metadata "P H I L O S O M A T I K A - Progressive Psytrance" "http://listen.radionomy.com:80/-PHILOSOMATIKAPROGRESSIVE-" 1 url)) |
| 80 | (*track* (type . streamlist) |
| 81 | (name . "http://www.bassdrive.com/BassDrive.m3u") |
| 82 | (metadata "Drum and Bass Radio, BassDrive" "http://www.bassdrive.com/BassDrive.m3u" 1 streamlist)) |
| 83 | (*track* (type . streamlist) |
| 84 | (name . "http://www.ibiblio.org/wcpe/wcpe.pls") |
| 85 | (metadata "WCPE, Classical Music" "http://www.ibiblio.org/wcpe/wcpe.pls" 1 streamlist)) |
| 86 | (*track* (type . streamlist) |
| 87 | (name . "http://stream.nute.net/kohina/stream.ogg.m3u") |
| 88 | (metadata "Kohina - Old school game and demo music" "http://stream.nute.net/kohina/stream.ogg.m3u" 1 streamlist)) |
| 89 | (*track* (type . streamlist) |
| 90 | (name . "http://privat.is-by.us:8000/necta192.mp3.m3u") |
| 91 | (metadata "Nectarine, Demoscene Radio, DE Continuum's relay 192 mp3" "http://privat.is-by.us:8000/necta192.mp3.m3u" 1 streamlist)) |
| 92 | (*track* (type . streamlist) |
| 93 | (name . "http://nectarine.from-de.com/necta192.m3u") |
| 94 | (metadata "Nectarine, Demoscene Radio, DE stream (High Bitrate)" "http://nectarine.from-de.com/necta192.m3u" 1 streamlist)) |
| 95 | (*track* (type . streamlist) |
| 96 | (name . "http://www.wfmu.org/wfmu.pls") |
| 97 | (metadata "WFMU, Freeform radio" "http://www.wfmu.org/wfmu.pls" 1 streamlist)) |
| 98 | (*track* (type . streamlist) |
| 99 | (name . "http://wfmu.org/wfmu_rock.pls") |
| 100 | (metadata "WFMU, Rock'n'Soul Ichiban!" "http://www.wfmu.org/wfmu.pls" 1 streamlist)) |
| 101 | (*track* (type . streamlist) |
| 102 | (name . "http://wfmu.org/wfmu_drummer.pls") |
| 103 | (metadata "WFMU, Give the Drummer Radio" "http://www.wfmu.org/wfmu.pls" 1 streamlist)) |
| 104 | (*track* (type . streamlist) |
| 105 | (name . "http://wfmu.org/wfmu_sheena.pls") |
| 106 | (metadata "WFMU, Sheena's Jungle Room" "http://www.wfmu.org/wfmu.pls" 1 streamlist)) |
| 107 | (*track* (type . streamlist) |
| 108 | (name . "http://nyc01.egihosting.com:6232/listen.pls") |
| 109 | (metadata "WBCR-LP - Berkshire Community Radio" "http://nyc01.egihosting.com:6232/listen.pls" 1 streamlist)) |
| 110 | (*track* (type . streamlist) |
| 111 | (name . "http://199.244.85.125:8000/wxhq1") |
| 112 | (metadata "WXHQ-LP - Newport Radio" "http://199.244.85.125:8000/wxhq1" 1 streamlist)))) |
| 113 | |
| 114 | (defcustom emms-streams-file (concat (file-name-as-directory emms-directory) |
| 115 | "streams.emms") |
| 116 | "A file used to store the built-in streams." |
| 117 | :group 'emms |
| 118 | :type 'file) |
| 119 | |
| 120 | |
| 121 | ;;; ------------------------------------------------------------------ |
| 122 | ;;; private functions |
| 123 | ;;; ------------------------------------------------------------------ |
| 124 | |
| 125 | (defun emms-streams-install-file (file) |
| 126 | "Install FILE, containing streams." |
| 127 | (when (not (file-directory-p (file-name-directory emms-streams-file))) |
| 128 | (make-directory (file-name-directory emms-streams-file))) |
| 129 | (if (or (not (file-exists-p file)) |
| 130 | (and (file-exists-p file) |
| 131 | (y-or-n-p (format "overwrite existing %s?" file)))) |
| 132 | (progn |
| 133 | (message "writing %s" file) |
| 134 | (with-temp-buffer |
| 135 | (insert emms-source-playlist-native-header-line) |
| 136 | (insert (format "\n%s\n\n" emms-streams-built-in-disclaimer)) |
| 137 | (insert |
| 138 | (concat "(" |
| 139 | (mapconcat |
| 140 | #'(lambda (e) |
| 141 | (format "%S" e)) |
| 142 | emms-streams-built-in-list "\n") |
| 143 | ")")) |
| 144 | (write-region (point-min) (point-max) file)) |
| 145 | (message "writing %s... done" file)) |
| 146 | (message "aborting"))) |
| 147 | |
| 148 | |
| 149 | ;;; ------------------------------------------------------------------ |
| 150 | ;;; interface |
| 151 | ;;; ------------------------------------------------------------------ |
| 152 | |
| 153 | (defun emms-streams-install () |
| 154 | "Install the built-in streams file." |
| 155 | (interactive) |
| 156 | (emms-streams-install-file emms-streams-file)) |
| 157 | |
| 158 | ;;;###autoload |
| 159 | (defun emms-streams () |
| 160 | "Create or switch to the built-in streaming audio playlist." |
| 161 | (interactive) |
| 162 | (when (and (not (file-exists-p emms-streams-file)) |
| 163 | (y-or-n-p "Emms' built-in streams file hasn't been installed yet. Install it now?")) |
| 164 | (emms-streams-install)) |
| 165 | (let ((buf (get-buffer emms-streams-buffer-name))) |
| 166 | (when (not buf) |
| 167 | (with-current-buffer (get-buffer-create emms-streams-buffer-name) |
| 168 | (setq buf (current-buffer)) |
| 169 | (emms-playlist-mode) |
| 170 | (setq emms-playlist-buffer-p t) |
| 171 | (emms-playlist-set-playlist-buffer (current-buffer)) |
| 172 | (emms-add-native-playlist emms-streams-file))) |
| 173 | (switch-to-buffer buf))) |
| 174 | |
| 175 | |
| 176 | (provide 'emms-streams) |
| 177 | |
| 178 | ;;; emms-streams.el ends here |