Rename ExternalInfo to ExternalMetadata

This commit is contained in:
Deluan
2021-02-09 11:41:47 -05:00
parent 5fdd8b32d7
commit 157faad028
7 changed files with 47 additions and 47 deletions
@@ -18,13 +18,13 @@ import (
const unavailableArtistID = "-1"
type ExternalInfo interface {
type ExternalMetadata interface {
UpdateArtistInfo(ctx context.Context, id string, count int, includeNotPresent bool) (*model.Artist, error)
SimilarSongs(ctx context.Context, id string, count int) (model.MediaFiles, error)
TopSongs(ctx context.Context, artist string, count int) (model.MediaFiles, error)
}
type externalInfo struct {
type externalMetadata struct {
ds model.DataStore
}
@@ -33,11 +33,11 @@ type auxArtist struct {
Name string
}
func NewExternalInfo2(ds model.DataStore) ExternalInfo {
return &externalInfo{ds: ds}
func NewExternalMetadata(ds model.DataStore) ExternalMetadata {
return &externalMetadata{ds: ds}
}
func (e *externalInfo) initAgents(ctx context.Context) []agents.Interface {
func (e *externalMetadata) initAgents(ctx context.Context) []agents.Interface {
order := strings.Split(conf.Server.Agents, ",")
order = append(order, agents.PlaceholderAgentName)
var res []agents.Interface
@@ -54,7 +54,7 @@ func (e *externalInfo) initAgents(ctx context.Context) []agents.Interface {
return res
}
func (e *externalInfo) getArtist(ctx context.Context, id string) (*auxArtist, error) {
func (e *externalMetadata) getArtist(ctx context.Context, id string) (*auxArtist, error) {
var entity interface{}
entity, err := GetEntityByID(ctx, e.ds, id)
if err != nil {
@@ -87,7 +87,7 @@ func clearName(name string) string {
return name
}
func (e *externalInfo) UpdateArtistInfo(ctx context.Context, id string, similarCount int, includeNotPresent bool) (*model.Artist, error) {
func (e *externalMetadata) UpdateArtistInfo(ctx context.Context, id string, similarCount int, includeNotPresent bool) (*model.Artist, error) {
allAgents := e.initAgents(ctx)
artist, err := e.getArtist(ctx, id)
if err != nil {
@@ -141,7 +141,7 @@ func (e *externalInfo) UpdateArtistInfo(ctx context.Context, id string, similarC
return &artist.Artist, nil
}
func (e *externalInfo) SimilarSongs(ctx context.Context, id string, count int) (model.MediaFiles, error) {
func (e *externalMetadata) SimilarSongs(ctx context.Context, id string, count int) (model.MediaFiles, error) {
allAgents := e.initAgents(ctx)
artist, err := e.getArtist(ctx, id)
if err != nil {
@@ -175,7 +175,7 @@ func (e *externalInfo) SimilarSongs(ctx context.Context, id string, count int) (
})
}
func (e *externalInfo) TopSongs(ctx context.Context, artistName string, count int) (model.MediaFiles, error) {
func (e *externalMetadata) TopSongs(ctx context.Context, artistName string, count int) (model.MediaFiles, error) {
allAgents := e.initAgents(ctx)
artist, err := e.findArtistByName(ctx, artistName)
if err != nil {
@@ -199,7 +199,7 @@ func (e *externalInfo) TopSongs(ctx context.Context, artistName string, count in
return mfs, nil
}
func (e *externalInfo) findMatchingTrack(ctx context.Context, mbid string, artistID, title string) (*model.MediaFile, error) {
func (e *externalMetadata) findMatchingTrack(ctx context.Context, mbid string, artistID, title string) (*model.MediaFile, error) {
if mbid != "" {
mfs, err := e.ds.MediaFile(ctx).GetAll(model.QueryOptions{
Filters: squirrel.Eq{"mbz_track_id": mbid},
@@ -233,7 +233,7 @@ func isDone(ctx context.Context) bool {
}
}
func (e *externalInfo) callGetMBID(ctx context.Context, allAgents []agents.Interface, artist *auxArtist) {
func (e *externalMetadata) callGetMBID(ctx context.Context, allAgents []agents.Interface, artist *auxArtist) {
start := time.Now()
for _, a := range allAgents {
if isDone(ctx) {
@@ -252,7 +252,7 @@ func (e *externalInfo) callGetMBID(ctx context.Context, allAgents []agents.Inter
}
}
func (e *externalInfo) callGetTopSongs(ctx context.Context, allAgents []agents.Interface, artist *auxArtist,
func (e *externalMetadata) callGetTopSongs(ctx context.Context, allAgents []agents.Interface, artist *auxArtist,
count int) ([]agents.Song, error) {
start := time.Now()
for _, a := range allAgents {
@@ -272,7 +272,7 @@ func (e *externalInfo) callGetTopSongs(ctx context.Context, allAgents []agents.I
return nil, nil
}
func (e *externalInfo) callGetURL(ctx context.Context, allAgents []agents.Interface, artist *auxArtist, wg *sync.WaitGroup) {
func (e *externalMetadata) callGetURL(ctx context.Context, allAgents []agents.Interface, artist *auxArtist, wg *sync.WaitGroup) {
wg.Add(1)
go func() {
defer wg.Done()
@@ -295,7 +295,7 @@ func (e *externalInfo) callGetURL(ctx context.Context, allAgents []agents.Interf
}()
}
func (e *externalInfo) callGetBiography(ctx context.Context, allAgents []agents.Interface, artist *auxArtist, wg *sync.WaitGroup) {
func (e *externalMetadata) callGetBiography(ctx context.Context, allAgents []agents.Interface, artist *auxArtist, wg *sync.WaitGroup) {
wg.Add(1)
go func() {
defer wg.Done()
@@ -321,7 +321,7 @@ func (e *externalInfo) callGetBiography(ctx context.Context, allAgents []agents.
}()
}
func (e *externalInfo) callGetImage(ctx context.Context, allAgents []agents.Interface, artist *auxArtist, wg *sync.WaitGroup) {
func (e *externalMetadata) callGetImage(ctx context.Context, allAgents []agents.Interface, artist *auxArtist, wg *sync.WaitGroup) {
wg.Add(1)
go func() {
defer wg.Done()
@@ -354,7 +354,7 @@ func (e *externalInfo) callGetImage(ctx context.Context, allAgents []agents.Inte
}()
}
func (e *externalInfo) callGetSimilar(ctx context.Context, allAgents []agents.Interface, artist *auxArtist, limit int, wg *sync.WaitGroup) {
func (e *externalMetadata) callGetSimilar(ctx context.Context, allAgents []agents.Interface, artist *auxArtist, limit int, wg *sync.WaitGroup) {
wg.Add(1)
go func() {
defer wg.Done()
@@ -382,7 +382,7 @@ func (e *externalInfo) callGetSimilar(ctx context.Context, allAgents []agents.In
}()
}
func (e *externalInfo) mapSimilarArtists(ctx context.Context, similar []agents.Artist, includeNotPresent bool) (model.Artists, error) {
func (e *externalMetadata) mapSimilarArtists(ctx context.Context, similar []agents.Artist, includeNotPresent bool) (model.Artists, error) {
var result model.Artists
var notPresent []string
@@ -407,7 +407,7 @@ func (e *externalInfo) mapSimilarArtists(ctx context.Context, similar []agents.A
return result, nil
}
func (e *externalInfo) findArtistByName(ctx context.Context, artistName string) (*auxArtist, error) {
func (e *externalMetadata) findArtistByName(ctx context.Context, artistName string) (*auxArtist, error) {
artists, err := e.ds.Artist(ctx).GetAll(model.QueryOptions{
Filters: squirrel.Like{"name": artistName},
Max: 1,
@@ -425,7 +425,7 @@ func (e *externalInfo) findArtistByName(ctx context.Context, artistName string)
return artist, nil
}
func (e *externalInfo) loadSimilar(ctx context.Context, artist *auxArtist, includeNotPresent bool) error {
func (e *externalMetadata) loadSimilar(ctx context.Context, artist *auxArtist, includeNotPresent bool) error {
var ids []string
for _, sa := range artist.SimilarArtists {
if sa.ID == unavailableArtistID {
+1 -1
View File
@@ -12,7 +12,7 @@ var Set = wire.NewSet(
GetImageCache,
NewArchiver,
NewNowPlayingRepository,
NewExternalInfo2,
NewExternalMetadata,
NewCacheWarmer,
NewPlayers,
transcoder.New,