mirror of
https://github.com/gesellix/Bose-SoundTouch.git
synced 2026-08-18 08:36:13 +00:00
✨ New Features: - Add SelectContentItem() method for direct ContentItem selection - Add SelectLocalInternetRadio() with full streamUrl format support - Add SelectLocalMusic() for SoundTouch App Media Server content - Add SelectStoredMusic() for UPnP/DLNA media server content 📻 streamUrl Format Support: - Full implementation of wiki specification for LOCAL_INTERNET_RADIO - Support for proxy URLs: http://contentapi.gmuth.de/station.php?name=Station&streamUrl=ActualStream - Direct stream URL support for simple internet radio - Complete ContentItem structure with metadata and artwork 🖥️ CLI Commands: - Add 'source internet-radio' command with streamUrl support - Add 'source local-music' command for local media server content - Add 'source stored-music' command for UPnP/DLNA content - Add 'source content' command for advanced generic selection - All commands include comprehensive flag support and validation 🧪 Testing: - Add 17+ comprehensive unit tests covering all scenarios - Test streamUrl format validation and parsing - Test error handling and parameter validation - Test default value assignment and ContentItem construction - All tests passing with full coverage 📚 Documentation: - Update CLI-REFERENCE.md with new command examples - Add complete content-selection example with working code - Add implementation summary document - Include API documentation for all new methods - Add usage examples for both API and CLI 🔗 References: Implements features from SoundTouch WebServices API Wiki: - https://github.com/thlucas1/homeassistantcomponent_soundtouchplus/wiki/SoundTouch-WebServices-API#select-local_internet_radio---streamurl-format - https://github.com/thlucas1/homeassistantcomponent_soundtouchplus/wiki/SoundTouch-WebServices-API#select-local_music 🎯 Benefits: - Complete API coverage for advanced content selection - Backward compatible with existing code - Flexible design with both convenience and power-user methods - Production-ready with comprehensive testing and documentation Co-authored-by: SoundTouch WebServices API Wiki <https://github.com/thlucas1/homeassistantcomponent_soundtouchplus>
5.8 KiB
5.8 KiB
Content Selection Example
This example demonstrates the advanced content selection features of the Bose SoundTouch Go client, including support for LOCAL_INTERNET_RADIO with streamUrl format, LOCAL_MUSIC, and STORED_MUSIC content.
Features Demonstrated
1. LOCAL_INTERNET_RADIO with streamUrl Format
- Uses proxy server format:
http://contentapi.gmuth.de/station.php?name=StationName&streamUrl=ActualStreamURL - Supports complex radio station metadata
- Artwork and station information
2. LOCAL_INTERNET_RADIO Direct Streams
- Direct HTTP/HTTPS stream URLs
- Simple internet radio playback
- MP3 and other audio format support
3. LOCAL_MUSIC Content
- SoundTouch App Media Server content
- Albums, tracks, artists, playlists
- Requires local SoundTouch Media Server running
4. STORED_MUSIC Content
- UPnP/DLNA media server content
- NAS libraries and Windows Media Player sharing
- Network-attached storage music libraries
5. Generic ContentItem Selection
- Direct ContentItem object creation
- Maximum flexibility for any content type
- All SoundTouch sources supported
Prerequisites
- SoundTouch device on your network
- Device IP address
- Go 1.21+ installed
Optional (for specific examples):
- LOCAL_MUSIC: SoundTouch App Media Server running on a computer
- STORED_MUSIC: UPnP/DLNA media server (Windows Media Player, NAS, etc.)
Usage
# Build and run
go run main.go <device_ip>
# Example
go run main.go 192.168.1.100
Example Output
🎵 SoundTouch Content Selection Example
📱 Device: 192.168.1.100:8090
📻 Step 1: Demonstrating LOCAL_INTERNET_RADIO with streamUrl format...
📡 Using streamUrl format with proxy server...
Station: Antenne Chillout
Proxy URL: http://contentapi.gmuth.de/station.php?name=Antenne%20Chillout&streamUrl=https://stream.antenne.de/chillout/stream/aacp
✅ Successfully selected internet radio with streamUrl format
🎵 Now Playing:
Title: Antenne Chillout
Source: LOCAL_INTERNET_RADIO
Status: Playing
Location: http://contentapi.gmuth.de/station.php?name=Antenne%20Chillout&streamUrl=https://stream.antenne.de/chillout/stream/aacp
📻 Step 2: Demonstrating LOCAL_INTERNET_RADIO with direct stream...
📡 Using direct stream URL...
Stream: Test Audio Stream
URL: https://freetestdata.com/wp-content/uploads/2021/09/Free_Test_Data_1MB_MP3.mp3
✅ Successfully selected direct internet radio stream
💿 Step 3: Demonstrating LOCAL_MUSIC selection...
⚠️ LOCAL_MUSIC demo failed (this requires SoundTouch App Media Server): failed to select local music: HTTP 404 Not Found
💾 Step 4: Demonstrating STORED_MUSIC selection...
⚠️ STORED_MUSIC demo failed (this requires UPnP/DLNA media server): failed to select stored music: HTTP 404 Not Found
🎯 Step 5: Demonstrating generic ContentItem selection...
🎯 Using generic ContentItem selection...
Content: K-LOVE Radio
Source: TUNEIN
Location: /v1/playbook/station/s33828
✅ Successfully selected content using ContentItem
✅ Content selection demo completed!
API Methods Demonstrated
SelectLocalInternetRadio
err := client.SelectLocalInternetRadio(location, sourceAccount, itemName, containerArt)
SelectLocalMusic
err := client.SelectLocalMusic(location, sourceAccount, itemName, containerArt)
SelectStoredMusic
err := client.SelectStoredMusic(location, sourceAccount, itemName, containerArt)
SelectContentItem (Advanced)
contentItem := &models.ContentItem{
Source: "LOCAL_INTERNET_RADIO",
Type: "stationurl",
Location: "http://contentapi.gmuth.de/station.php?name=MyStation&streamUrl=https://stream.example.com/radio",
SourceAccount: "",
IsPresetable: true,
ItemName: "My Radio Station",
ContainerArt: "https://example.com/art.png",
}
err := client.SelectContentItem(contentItem)
CLI Usage Examples
These API methods are also available via the CLI:
# Internet radio with streamUrl format
soundtouch-cli --host 192.168.1.100 source internet-radio \
--location "http://contentapi.gmuth.de/station.php?name=MyStation&streamUrl=https://stream.example.com/radio" \
--name "My Station" \
--artwork "https://example.com/art.png"
# Local music content
soundtouch-cli --host 192.168.1.100 source local-music \
--location "album:983" \
--account "3f205110-4a57-4e91-810a-123456789012" \
--name "Welcome to the New"
# Stored music content
soundtouch-cli --host 192.168.1.100 source stored-music \
--location "6_a2874b5d_4f83d999" \
--account "d09708a1-5953-44bc-a413-123456789012/0" \
--name "Christmas Album"
# Generic content selection (advanced)
soundtouch-cli --host 192.168.1.100 source content \
--source LOCAL_INTERNET_RADIO \
--location "https://stream.example.com/radio" \
--name "My Stream" \
--type stationurl \
--presetable
Implementation Notes
streamUrl Format
The streamUrl format uses a proxy server that accepts the actual stream URL as a parameter. This allows for:
- Complex metadata handling
- Stream URL obfuscation
- Cross-origin request handling
- Additional processing capabilities
ContentItem Structure
All content selection methods create a ContentItem with appropriate defaults:
Typeis automatically set based on sourceIsPresetabledefaults to trueItemNamegets a sensible default if not provided
Error Handling
The example gracefully handles missing services:
- LOCAL_MUSIC requires SoundTouch App Media Server
- STORED_MUSIC requires UPnP/DLNA media server
- Some internet streams may be geo-restricted