# RadioPlayer

RadioPlayer is a Vite + React web app for browsing, playing, and casting radio stations. It loads its station catalog from `public/stations.json`, supports custom stations, and includes a built-in updater for refreshing that list from the live Radio.si feed.

## Features

- Station browser with search, categories, favourites, and recent stations
- Audio playback with previous/next station controls
- Cast support
- Production service worker for app-shell caching, offline launch support, and faster repeat visits
- App install prompt for supported browsers
- Custom station editor
- Live station metadata and artwork rendering

## Requirements

- Node.js 18 or newer
- npm

## Getting Started

Install dependencies:

```bash
npm install
```

Start the development server:

```bash
npm run dev
```

Build for production:

```bash
npm run build
```

Preview the production build:

```bash
npm run preview
```

## Station Data

The app reads station data from `public/stations.json`.

To refresh the file from the remote source, run:

```bash
npm run update:stations
```

That command fetches the latest station list from:

```text
https://data.radio.si/api/radiostations?857df78efd094abcb98c7bbb53303c3d
```

and rewrites `public/stations.json` while preserving the existing JSON structure used by the app.

You can also pass a custom source URL or a custom output path if needed:

```bash
node scripts/update-stations.mjs <source-url> <output-path>
```

## Project Structure

```text
index.html
package.json
public/
  manifest.json
  stations.json
  sw.js
src/
  App.jsx
  main.jsx
  player.js
  styles.css
scripts/
  update-stations.mjs
```

## Notes

- The app uses a module-based frontend build, so `src/main.jsx` is the browser entry point.
- The service worker is registered only in production builds. During development, existing service workers and caches are cleared automatically to avoid stale assets while iterating.
- The updater script uses the remote feed as the source of truth for the station list and writes the merged result into `public/stations.json`.
- If you add or edit stations manually, re-run `npm run update:stations` when you want to sync back to the remote catalog.
