diff --git a/cmd/dwelling-radio/main.go b/cmd/dwelling-radio/main.go index a7f1bbb..d34b58b 100644 --- a/cmd/dwelling-radio/main.go +++ b/cmd/dwelling-radio/main.go @@ -50,6 +50,7 @@ func main() { srv.GET("/status", hand.Status) srv.GET("/lastsong", hand.LastSong) srv.GET("/playlist", hand.Playlist) + srv.GET("/filelist", hand.Filelist) if !*noLiquidsoap { liquid, err := radio.NewLiquidsoap(config.Liquidsoap.ExecPath, config.Liquidsoap.ScriptPath) diff --git a/configs/config.yaml b/configs/config.yaml index ce65e72..7877e65 100644 --- a/configs/config.yaml +++ b/configs/config.yaml @@ -6,6 +6,7 @@ icecast: # URL to Icecast's status-json.xsl url: "http://radio.arav.home.arpa/status-json.xsl" playlist_path: "/var/log/icecast/playlist.log" +filelist_path: "/srv/radio/filelist.html" liquidsoap: executable_path: "/opt/opam/4.14.0/bin/liquidsoap" script_path: "/etc/dwelling/radio.liq" diff --git a/configs/nginx.conf b/configs/nginx.conf index af7a501..6210611 100644 --- a/configs/nginx.conf +++ b/configs/nginx.conf @@ -26,12 +26,6 @@ server { proxy_set_header Host $host; } - - location =/filelist { - alias $http_root/shared/radio_filelist.html; - default_type text/html; - } - location =/robots.txt { alias $http_root/shared/files/radio.robots.txt; default_type text/html; diff --git a/internal/configuration/configuration.go b/internal/configuration/configuration.go index 3e7e149..b2178e4 100644 --- a/internal/configuration/configuration.go +++ b/internal/configuration/configuration.go @@ -14,7 +14,8 @@ type Configuration struct { URL string `yaml:"url"` Playlist string `yaml:"playlist_path"` } `yaml:"icecast"` - Liquidsoap struct { + FilelistPath string `yaml:"filelist_path"` + Liquidsoap struct { ExecPath string `yaml:"executable_path"` ScriptPath string `yaml:"script_path"` } `yaml:"liquidsoap"` diff --git a/internal/http/handlers.go b/internal/http/handlers.go index 32f9eec..97865d8 100644 --- a/internal/http/handlers.go +++ b/internal/http/handlers.go @@ -8,6 +8,7 @@ import ( "encoding/json" "log" "net/http" + "os" "time" ) @@ -98,3 +99,8 @@ func (h *Handlers) Playlist(w http.ResponseWriter, _ *http.Request) { fc, _ := web.AssetsGetFile("radio.arav.top.m3u") w.Write(fc) } + +func (h *Handlers) Filelist(w http.ResponseWriter, _ *http.Request) { + data, _ := os.ReadFile(h.conf.FilelistPath) + w.Write(data) +}