// Package main demonstrates music service account management functionality for Bose SoundTouch devices. package main import ( "fmt" "log" "time" "github.com/gesellix/bose-soundtouch/pkg/client" "github.com/gesellix/bose-soundtouch/pkg/models" ) func main() { // Configure the SoundTouch client config := &client.Config{ Host: "192.0.2.100", // Replace with your device IP Port: 8090, Timeout: 10 * time.Second, } // Create client soundtouchClient := client.NewClient(config) fmt.Printf("šŸŽµ SoundTouch Music Service Account Management Example\n") fmt.Printf("Device: %s:%d\n\n", config.Host, config.Port) // Example 1: Add a Spotify account using convenience method fmt.Println("šŸ“± Adding Spotify Premium account...") err := soundtouchClient.AddSpotifyAccount("user@spotify.com", "your_password") if err != nil { log.Printf("Failed to add Spotify account: %v", err) } else { fmt.Println("āœ… Spotify account added successfully") } // Example 2: Add a Pandora account fmt.Println("\nšŸ“» Adding Pandora account...") err = soundtouchClient.AddPandoraAccount("pandora_username", "pandora_password") if err != nil { log.Printf("Failed to add Pandora account: %v", err) } else { fmt.Println("āœ… Pandora account added successfully") } // Example 3: Add Amazon Music account fmt.Println("\nšŸ›’ Adding Amazon Music account...") err = soundtouchClient.AddAmazonMusicAccount("amazon_user", "amazon_password") if err != nil { log.Printf("Failed to add Amazon Music account: %v", err) } else { fmt.Println("āœ… Amazon Music account added successfully") } // Example 4: Add a network music library (NAS/UPnP) fmt.Println("\nšŸ  Adding network music library...") nasGUID := "d09708a1-5953-44bc-a413-123456789012/0" // Example UPnP server GUID err = soundtouchClient.AddStoredMusicAccount(nasGUID, "My Home Music Server") if err != nil { log.Printf("Failed to add network music library: %v", err) } else { fmt.Println("āœ… Network music library added successfully") } // Example 5: Add account using generic method with custom credentials fmt.Println("\nšŸŽ§ Adding Deezer account using generic method...") deezerCredentials := models.NewDeezerCredentials("deezer_user", "deezer_password") err = soundtouchClient.SetMusicServiceAccount(deezerCredentials) if err != nil { log.Printf("Failed to add Deezer account: %v", err) } else { fmt.Println("āœ… Deezer account added successfully") } // Example 6: Add a custom/unknown service fmt.Println("\nšŸŽ¶ Adding custom music service...") customCredentials := models.NewMusicServiceCredentials("TIDAL", "Tidal HiFi", "tidal_user", "tidal_password") err = soundtouchClient.SetMusicServiceAccount(customCredentials) if err != nil { log.Printf("Failed to add custom music service: %v", err) } else { fmt.Println("āœ… Custom music service added successfully") } // Example 7: List current sources to see added accounts fmt.Println("\nšŸ“‹ Checking available sources...") sources, err := soundtouchClient.GetSources() if err != nil { log.Printf("Failed to get sources: %v", err) } else { fmt.Printf("Available sources (%d total):\n", len(sources.SourceItem)) for _, source := range sources.SourceItem { status := "šŸ”“ Unavailable" if source.Status == models.SourceStatusReady { status = "🟢 Ready" } accountInfo := "" if source.SourceAccount != "" && source.SourceAccount != source.Source { accountInfo = fmt.Sprintf(" (%s)", source.SourceAccount) } fmt.Printf(" %s %s%s\n", status, source.GetDisplayName(), accountInfo) } } // Example 8: Remove accounts fmt.Println("\nšŸ—‘ļø Removing accounts...") // Remove Spotify account err = soundtouchClient.RemoveSpotifyAccount("user@spotify.com") if err != nil { log.Printf("Failed to remove Spotify account: %v", err) } else { fmt.Println("āœ… Spotify account removed successfully") } // Remove Deezer account using generic method deezerRemovalCredentials := models.NewDeezerCredentials("deezer_user", "") err = soundtouchClient.RemoveMusicServiceAccount(deezerRemovalCredentials) if err != nil { log.Printf("Failed to remove Deezer account: %v", err) } else { fmt.Println("āœ… Deezer account removed successfully") } // Remove network music library err = soundtouchClient.RemoveStoredMusicAccount(nasGUID, "My Home Music Server") if err != nil { log.Printf("Failed to remove network music library: %v", err) } else { fmt.Println("āœ… Network music library removed successfully") } fmt.Println("\nšŸŽ‰ Account management example completed!") fmt.Println("\nšŸ’” Tips:") fmt.Println(" • Use 'account list' to see which services are configured") fmt.Println(" • After adding accounts, use 'source list' to verify availability") fmt.Println(" • Network libraries (NAS/UPnP) don't require passwords") fmt.Println(" • Some services may need additional authentication via their mobile apps") fmt.Println(" • Account credentials are stored securely on the SoundTouch device") }