Remove redundant interfaces

This commit is contained in:
Deluan 2020-10-20 15:46:18 -04:00 committed by Deluan Quintão
parent a257891b46
commit a289a1945f
3 changed files with 7 additions and 16 deletions

View File

@ -50,9 +50,9 @@ func CreateSubsonicAPIRouter() (*subsonic.Router, error) {
mediaStreamer := core.NewMediaStreamer(dataStore, transcoderTranscoder, transcodingCache)
archiver := core.NewArchiver(dataStore)
players := engine.NewPlayers(dataStore)
lastFMClient := core.LastFMNewClient()
client := core.LastFMNewClient()
spotifyClient := core.SpotifyNewClient()
externalInfo := core.NewExternalInfo(dataStore, lastFMClient, spotifyClient)
externalInfo := core.NewExternalInfo(dataStore, client, spotifyClient)
router := subsonic.New(artwork, listGenerator, playlists, mediaStreamer, archiver, players, externalInfo, dataStore)
return router, nil
}

View File

@ -26,23 +26,14 @@ type ExternalInfo interface {
SimilarSongs(ctx context.Context, id string, count int) (model.MediaFiles, error)
}
type LastFMClient interface {
ArtistGetInfo(ctx context.Context, name string) (*lastfm.Artist, error)
ArtistGetSimilar(ctx context.Context, name string, limit int) ([]lastfm.Artist, error)
}
type SpotifyClient interface {
SearchArtists(ctx context.Context, name string, limit int) ([]spotify.Artist, error)
}
func NewExternalInfo(ds model.DataStore, lfm LastFMClient, spf SpotifyClient) ExternalInfo {
func NewExternalInfo(ds model.DataStore, lfm *lastfm.Client, spf *spotify.Client) ExternalInfo {
return &externalInfo{ds: ds, lfm: lfm, spf: spf}
}
type externalInfo struct {
ds model.DataStore
lfm LastFMClient
spf SpotifyClient
lfm *lastfm.Client
spf *spotify.Client
}
func (e *externalInfo) getArtist(ctx context.Context, id string) (artist *model.Artist, err error) {

View File

@ -22,7 +22,7 @@ var Set = wire.NewSet(
transcoder.New,
)
func LastFMNewClient() LastFMClient {
func LastFMNewClient() *lastfm.Client {
if conf.Server.LastFM.ApiKey == "" {
return nil
}
@ -30,7 +30,7 @@ func LastFMNewClient() LastFMClient {
return lastfm.NewClient(conf.Server.LastFM.ApiKey, conf.Server.LastFM.Language, http.DefaultClient)
}
func SpotifyNewClient() SpotifyClient {
func SpotifyNewClient() *spotify.Client {
if conf.Server.Spotify.ID == "" || conf.Server.Spotify.Secret == "" {
return nil
}