feat: add Navidrome client with Subsonic API sync
Add the Navidrome client module that connects to a Navidrome server via the Subsonic API, fetches artist and album data, and syncs it into the local SQLite database. - Add go-subsonic dependency for Subsonic API communication - Create internal/navidrome/client.go with NavidromeClient wrapper - NewClient constructor with token-based auth - Ping health check with HTTP status validation - GetArtists fetches all artists via getArtists endpoint - GetArtistAlbums fetches albums per artist via getArtist endpoint - Create internal/navidrome/sync.go with sync orchestration - SyncArtists upserts artists into artist_settings table - SyncAlbums fetches and stores albums for monitored artists - Add local_albums table (migration 003) with FK to artist_settings - Add LocalAlbum CRUD operations in internal/database/local_albums.go - Full test coverage: 19 tests across client and sync packages - All tests pass, go vet and go fmt clean
This commit is contained in:
@@ -7,10 +7,11 @@
|
||||
|
||||
|
||||
## 2. Технологический стек
|
||||
* **Язык программирования:** Go 1.21+
|
||||
* **Язык программирования:** Go 1.25+
|
||||
* **База данных:** SQLite 3 (для хранения кэша, настроек и состояний).
|
||||
* **HTTP-сервер:** Стандартная библиотека Go (`net/http`) + `html/template`.
|
||||
* **Внешние зависимости (библиотеки):**
|
||||
* `github.com/delucks/go-subsonic` — клиент Subsonic API (getArtists, getArtist, ping).
|
||||
* `github.com/mattn/go-sqlite3` — драйвер базы данных.
|
||||
* `github.com/lithammer/fuzzysearch` — библиотека для нечеткого сравнения строк.
|
||||
* `gopkg.in/yaml.v3` — парсинг конфигурационных файлов.
|
||||
@@ -89,6 +90,14 @@ NaviWatcher взаимодействует с Navidrome через **Subsonic AP
|
||||
* `release_date`: string
|
||||
* `is_ignored`: boolean (флаг скрытия из списка новинок)
|
||||
|
||||
### Таблица `local_albums`
|
||||
Локальные альбомы, синхронизированные из Navidrome через Subsonic API.
|
||||
* `id`: string — Subsonic album ID, Primary Key.
|
||||
* `artist_id`: string — FK → `artist_settings.id`.
|
||||
* `title`: string — название альбома.
|
||||
|
||||
**Решение по хранению локальных альбомов:** Для локальных альбомов используется отдельная таблица `local_albums` (вариант 1 из трёх рассмотренных). Это обеспечивает чистое разделение ответственности: `external_releases` хранит данные MusicBrainz (Release Groups), а `local_albums` — данные Navidrome. Смешивание этих сущностей в одной таблице (через колонку `source` или флаг) усложнило бы запросы и фильтрацию, а также привело бы к неоднородности схемы (разные типы ID, разные наборы полей).
|
||||
|
||||
### Таблица `notifications_sent`
|
||||
* `rgid`: string (FK)
|
||||
* `sent_at`: datetime
|
||||
|
||||
Reference in New Issue
Block a user