Files
AppleSync/internal/model/model.go
T
2026-11-26 15:11:41 +01:00

106 lines
4.0 KiB
Go

// Package model contains the types shared between the Apple, Qobuz, matcher,
// library and m3u packages.
package model
import "time"
// Track is a track from an Apple Music playlist.
type Track struct {
AppleID string `json:"apple_id"`
Title string `json:"title"`
ArtistName string `json:"artist_name"`
Artists []string `json:"artists,omitempty"`
AlbumName string `json:"album_name"`
AlbumID string `json:"album_id"`
AlbumArtist string `json:"album_artist,omitempty"`
AlbumUPC string `json:"album_upc,omitempty"`
AlbumTrackCount int `json:"album_track_count,omitempty"`
AlbumReleaseDate string `json:"album_release_date,omitempty"`
ISRC string `json:"isrc,omitempty"`
DurationMS int `json:"duration_ms"`
TrackNumber int `json:"track_number,omitempty"`
DiscNumber int `json:"disc_number,omitempty"`
Explicit bool `json:"explicit,omitempty"`
}
// Album is an Apple Music album referenced by one or more playlist tracks.
// Tracks contains only the tracks that occur in the playlist, not the full
// album.
type Album struct {
AppleID string `json:"apple_id"`
Title string `json:"title"`
Artist string `json:"artist"`
UPC string `json:"upc,omitempty"`
TrackCount int `json:"track_count,omitempty"`
ReleaseDate string `json:"release_date,omitempty"`
Year int `json:"year,omitempty"`
Tracks []*Track `json:"tracks"`
}
// Playlist is the result of fetching one Apple Music playlist.
type Playlist struct {
URL string `json:"url"`
SourceID string `json:"source_id"`
Storefront string `json:"storefront"`
Name string `json:"name"`
Tracks []*Track `json:"tracks"`
Albums []*Album `json:"albums"`
}
// QobuzTrack is a track from a Qobuz album.
type QobuzTrack struct {
ID int64 `json:"id"`
Title string `json:"title"`
ISRC string `json:"isrc,omitempty"`
TrackNumber int `json:"track_number,omitempty"`
DiscNumber int `json:"disc_number,omitempty"`
Duration int `json:"duration,omitempty"`
}
// QobuzAlbum is an album returned by the Qobuz search or get endpoints.
type QobuzAlbum struct {
ID string `json:"id"`
Title string `json:"title"`
Artist string `json:"artist"`
UPC string `json:"upc,omitempty"`
Year int `json:"year,omitempty"`
TrackCount int `json:"track_count,omitempty"`
BitDepth int `json:"bit_depth,omitempty"`
SampleRate float64 `json:"sample_rate,omitempty"`
Tracks []QobuzTrack `json:"tracks,omitempty"`
}
// AlbumMatch records how an Apple album was matched to Qobuz.
type AlbumMatch struct {
AppleAlbumID string `json:"apple_album_id"`
QobuzAlbumID string `json:"qobuz_album_id"`
QobuzTitle string `json:"qobuz_title"`
QobuzArtist string `json:"qobuz_artist"`
QobuzUPC string `json:"qobuz_upc,omitempty"`
QobuzTrackCount int `json:"qobuz_track_count,omitempty"`
Method string `json:"method"` // upc, fuzzy, isrc
Confidence float64 `json:"confidence"`
CheckedAt time.Time `json:"checked_at"`
}
// CachedMatch is the persisted form of an album match lookup. A nil Match with
// a non-empty Error is a negative cache entry.
type CachedMatch struct {
Match *AlbumMatch `json:"match,omitempty"`
Error string `json:"error,omitempty"`
CheckedAt time.Time `json:"checked_at"`
}
// FileEntry is one tagged audio file discovered in the download library.
type FileEntry struct {
Path string `json:"path"`
ISRC string `json:"isrc,omitempty"`
Title string `json:"title"`
Artist string `json:"artist"`
Album string `json:"album"`
AlbumArtist string `json:"album_artist,omitempty"`
TrackNumber int `json:"track_number,omitempty"`
DiscNumber int `json:"disc_number,omitempty"`
Format string `json:"format,omitempty"`
}