sonda/internal/opensubsonic/store.go
tgiachi 1ae8e77d81 feat: OpenSubsonic core, login with a device password
/rest speaks the OpenSubsonic API (Subsonic 1.16.1) so that other apps can browse
the music of a server. A call logs in with the password of a device: an apiKey,
Subsonic's token (u, t, s) or the password itself (u, p). The account password is
never accepted there.

- devices: ByKey, ByToken, ByPassword and the note of last use
- opensubsonic package: JSON and XML answers, ping, getLicense,
  getOpenSubsonicExtensions, tokenInfo, getMusicFolders, getArtists, getArtist,
  getAlbum, getSong, getGenres
- storage.SubsonicRepo: year, genres, size, bitrate, suffix and added date
2026-11-16 09:32:11 +01:00

40 lines
1.2 KiB
Go

package opensubsonic
import (
"context"
"time"
)
// TrackExtra is what an app asks about a song that the catalogue does not carry: from its tags and its first file.
type TrackExtra struct {
Year int // 0 when the file has none
Genres []string
Size int64 // bytes
BitrateKbps int // 0 when unknown
Suffix string // the extension of the file, without the dot
AddedAt time.Time
}
// AlbumExtra is the same for an album.
type AlbumExtra struct {
Year int // the earliest year of its songs, 0 when none has one
Genres []string
AddedAt time.Time // when its oldest file arrived
}
// Genre is a genre of the music, with how much of it there is.
type Genre struct {
Name string
Songs int
Albums int
}
// Extras reads what the catalogue does not carry.
type Extras interface {
// Tracks returns the extras of the songs that can be played; a song that cannot is left out.
Tracks(ctx context.Context, ids []int64) (map[int64]TrackExtra, error)
// Albums returns the extras of the albums that can be played.
Albums(ctx context.Context, ids []int64) (map[int64]AlbumExtra, error)
// Genres returns every genre of the songs that can be played.
Genres(ctx context.Context) ([]Genre, error)
}