# Suno Radio (GoLang)

Suno radio in golang. Working demo; to be rewritten in python for glockenspeil.

## Run

Get the Go CLI.

In .env, set `SUNO_BEARER_TOKEN=YOUR_EXTERNAL_API_TOKEN`.

Then do `go run .`

## Testing

There are 2 test files under `{file_name}_test.go`.

## REST API Interface

The radio server runs on port 8080 and provides the following REST API endpoints. All endpoints support CORS with `Access-Control-Allow-Origin: *`.

### POST /vote

Submit a vote for a music style.

**Request:**

- Method: `POST`
- Content-Type: `application/x-www-form-urlencoded`
- Body parameter: `vote` (string) - The style name to vote for

**Response:**

- Status: `200 OK` (no response body)

**Example:**

```bash
curl -X POST http://localhost:8080/vote -d "vote=Electronic"
```

### GET /song-list

Retrieve the list of recent songs (up to last 10 songs).

**Request:**

- Method: `GET`

**Response:**

- Content-Type: `application/json`
- Body: Array of song objects

**Song Object Structure:**

```json
{
  "songUrl": "string", // URL to the audio file
  "imageUrl": "string", // URL to the song artwork
  "title": "string", // Song title
  "description": "string", // Song description/prompt
  "tags": ["string"], // Array of tags
  "startTime": "2024-01-01T00:00:00Z", // ISO timestamp when song started
  "duration": 175.88 // Duration in seconds (float)
}
```

**Example:**

```bash
curl http://localhost:8080/song-list
```

### GET /vote-status

Get the current voting status including available styles, vote counts, and when voting closes.

**Request:**

- Method: `GET`

**Response:**

- Content-Type: `application/json`
- Body: Vote status object

**Vote Status Object Structure:**

```json
{
  "styles": ["string"], // Array of 4 current voting options
  "votes": [0, 0, 0, 0], // Array of vote counts for each style
  "votesCloseAt": "2024-01-01T00:00:00Z" // ISO timestamp when voting closes (null if closed)
}
```

**Notes:**

- Voting closes 90 seconds before the current song ends
- When voting is closed, `votesCloseAt` will be `null`
- Styles are randomly selected from a predefined list for each voting round
- Vote counts are reset when a new song begins

**Example:**

```bash
curl http://localhost:8080/vote-status
```

## Available Music Styles

The system randomly selects 4 styles from the following list for each voting round:

Chill, Energetic, Party, Ambient, Lo-fi, Jazz, Electronic, Tropical House, Deep House, Techno, Trance, Dubstep, Drum & Bass, Synthwave, Vaporwave, Future Bass, Trap, Hardstyle, Progressive House, Minimal, Downtempo, Chillstep, Liquid DnB, Psytrance, Breakbeat, Garage, Afrobeat, Latin, Reggaeton, Bossa Nova, Salsa, Flamenco, Celtic, Nordic, Mediterranean, Middle Eastern, Asian Fusion, Bollywood, K-Pop, J-Pop, City Pop, Funk, Disco, Soul, R&B, Gospel, Blues, Rock, Indie, Folk, Country, Bluegrass, Classical, Baroque, Romantic, Modern Classical, Cinematic, Epic, Dark, Ethereal, Mystical, Retro, 80s, 90s, 2000s, Acoustic, Piano, Orchestral, String Quartet, Brass, Woodwind, Percussive, Nature, Ocean, Forest, Urban, Industrial, Glitch, Noise, Drone, Meditation, Yoga, Spa, Study, Sleep, Morning, Sunset, Night, Space, Cyberpunk, Steampunk, Fantasy, 8-bit, Chipwave, Kawaii, Melancholic, Euphoric, Aggressive, Experimental, House
