feat: create MusicBrainz client and data models
Add internal/musicbrainz/ package with: - client.go: MusicBrainzClient struct wrapping net/http.Client with channel-based rate limiter (1 req/sec), doGet method with proper User-Agent header, and Close for cleanup - model.go: ReleaseGroup, Artist, ExternalRelease, and Parsed* structs - XML parsing functions for release-group list and artist responses - Comprehensive tests: XML parsing (success, empty, malformed), client constructor, doGet (success, non-200, unreachable server), rate limiter behavior
This commit is contained in:
46
internal/musicbrainz/model.go
Normal file
46
internal/musicbrainz/model.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package musicbrainz
|
||||
|
||||
import "time"
|
||||
|
||||
// ReleaseGroup represents a MusicBrainz Release Group entity.
|
||||
// This is the primary data model for the provider - we work with
|
||||
// Release Groups to minimize duplicates from different releases.
|
||||
type ReleaseGroup struct {
|
||||
ID string
|
||||
Title string
|
||||
Type string
|
||||
Status string
|
||||
ArtistID string
|
||||
ArtistName string
|
||||
ReleaseDate string
|
||||
}
|
||||
|
||||
// Artist represents a MusicBrainz artist entity.
|
||||
type Artist struct {
|
||||
ID string
|
||||
Name string
|
||||
}
|
||||
|
||||
// ExternalRelease is the normalized form stored in the database,
|
||||
// matching the external_releases table schema.
|
||||
type ExternalRelease struct {
|
||||
RGID string
|
||||
ArtistID string
|
||||
Title string
|
||||
Type string
|
||||
ReleaseDate string
|
||||
CachedAt time.Time
|
||||
}
|
||||
|
||||
// ParsedReleaseGroups holds the result of parsing a MusicBrainz
|
||||
// release-group list XML response.
|
||||
type ParsedReleaseGroups struct {
|
||||
ReleaseGroups []ReleaseGroup
|
||||
Count int
|
||||
}
|
||||
|
||||
// ParsedArtist holds the result of parsing a MusicBrainz artist lookup.
|
||||
type ParsedArtist struct {
|
||||
ID string
|
||||
Name string
|
||||
}
|
||||
Reference in New Issue
Block a user