Add SearchArtists and GetArtistAlbums proxy RPCs to music-agregator service

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/claude-agent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
Alexander
2026-05-11 10:30:18 +02:00
parent ad03caa3f4
commit eab92dd40b
4 changed files with 205 additions and 0 deletions
+103
View File
@@ -869,3 +869,106 @@ func downloadTorrentData(url string) ([]byte, error) {
return data, nil
}
func (service *MusicAgregatorService) SearchArtists(ctx context.Context, req *pb.SearchArtistsRequest) (*pb.SearchArtistsResponse, error) {
resp, err := service.metadata.SearchArtists(ctx, req.GetQuery(), req.GetLimit(), req.GetOffset())
if err != nil {
return nil, err
}
artists := make([]*pb.SearchArtistResult, len(resp.GetArtists()))
for i, a := range resp.GetArtists() {
genres := make([]string, len(a.GetGenres()))
for j, g := range a.GetGenres() {
genres[j] = g.GetName()
}
extIDs := make([]*pb.ExternalId, len(a.GetExternalIds()))
for j, e := range a.GetExternalIds() {
extIDs[j] = &pb.ExternalId{
Provider: e.GetSource(),
Id: e.GetSourceId(),
}
}
artists[i] = &pb.SearchArtistResult{
Id: a.GetId(),
Name: a.GetName(),
SortName: a.GetSortName(),
ArtistType: a.GetArtistType(),
Country: a.GetCountry(),
FormedDate: a.GetFormedDate(),
DisbandedDate: a.GetDisbandedDate(),
Description: a.GetDescription(),
ImageUrl: a.GetImageUrl(),
Genres: genres,
ExternalIds: extIDs,
}
}
return &pb.SearchArtistsResponse{
Artists: artists,
Total: resp.GetTotal(),
}, nil
}
func (service *MusicAgregatorService) GetArtistAlbums(ctx context.Context, req *pb.GetArtistAlbumsRequest) (*pb.GetArtistAlbumsResponse, error) {
resp, err := service.metadata.GetArtistAlbumsWithPagination(ctx, req.GetArtistId(), req.GetLimit(), req.GetOffset())
if err != nil {
return nil, err
}
albums := make([]*pb.AlbumResult, len(resp.GetAlbums()))
for i, a := range resp.GetAlbums() {
genres := make([]string, len(a.GetGenres()))
for j, g := range a.GetGenres() {
genres[j] = g.GetName()
}
extIDs := make([]*pb.ExternalId, len(a.GetExternalIds()))
for j, e := range a.GetExternalIds() {
extIDs[j] = &pb.ExternalId{
Provider: e.GetSource(),
Id: e.GetSourceId(),
}
}
artists := make([]*pb.AlbumArtistCredit, len(a.GetArtists()))
for j, ac := range a.GetArtists() {
artists[j] = &pb.AlbumArtistCredit{
Id: ac.GetArtist().GetId(),
Name: ac.GetArtist().GetName(),
Role: ac.GetRole(),
}
}
var label *pb.AlbumLabel
if a.GetLabel() != nil {
label = &pb.AlbumLabel{
Id: a.GetLabel().GetId(),
Name: a.GetLabel().GetName(),
Country: a.GetLabel().GetCountry(),
}
}
albums[i] = &pb.AlbumResult{
Id: a.GetId(),
Title: a.GetTitle(),
AlbumType: a.GetAlbumType(),
ReleaseDate: a.GetReleaseDate(),
Upc: a.GetUpc(),
TotalTracks: a.GetTotalTracks(),
TotalDiscs: a.GetTotalDiscs(),
CoverUrl: a.GetCoverUrl(),
Artists: artists,
Label: label,
Genres: genres,
ExternalIds: extIDs,
}
}
return &pb.GetArtistAlbumsResponse{
Albums: albums,
Total: resp.GetTotal(),
}, nil
}