Files
Bose-SoundTouch/pkg/service/bmx/bmx.go
T
Tobias Gesellchen b95bdae751 feat: Add RadioBrowser integration alongside TuneIn support
- Refactors BMX service to support multiple radio providers
- Adds RadioBrowser.com API integration with search and browse
- Splits TuneIn logic into separate module for better organization
- Adds new web UI components for radio station discovery
- Includes new SVG icons for RadioBrowser branding
2026-05-18 22:34:26 +02:00

58 lines
1.4 KiB
Go

// Package bmx implements minimal helper calls to public music service endpoints
// like TuneIn and RadioBrowser and wraps them into Bose-compatible
// response models.
package bmx
import (
"encoding/json"
"github.com/gesellix/bose-soundtouch/pkg/models"
)
// BuildCustomStreamResponse builds a playback response from streamUrl, imageUrl, and name.
func BuildCustomStreamResponse(streamURL, imageURL, name string) (*models.BmxPlaybackResponse, error) {
streamList := []models.Stream{
{
HasPlaylist: true,
IsRealtime: true,
StreamUrl: streamURL,
},
}
audio := models.Audio{
HasPlaylist: true,
IsRealtime: true,
StreamUrl: streamURL,
Streams: streamList,
}
response := &models.BmxPlaybackResponse{
Audio: audio,
ImageUrl: imageURL,
Name: name,
StreamType: "liveRadio",
}
return response, nil
}
// PlayCustomStream builds a playback response from a base64-encoded JSON blob
// with fields streamUrl, imageUrl, and name.
func PlayCustomStream(data string) (*models.BmxPlaybackResponse, error) {
jsonStr, err := decodeBase64URI(data)
if err != nil {
return nil, err
}
var jsonObj struct {
StreamURL string `json:"streamUrl"`
ImageURL string `json:"imageUrl"`
Name string `json:"name"`
}
if err := json.Unmarshal([]byte(jsonStr), &jsonObj); err != nil {
return nil, err
}
return BuildCustomStreamResponse(jsonObj.StreamURL, jsonObj.ImageURL, jsonObj.Name)
}