From a289a1945f01283b44264ccc3b82c9c46d01fc02 Mon Sep 17 00:00:00 2001 From: Deluan Date: Tue, 20 Oct 2020 15:46:18 -0400 Subject: [PATCH] Remove redundant interfaces --- cmd/wire_gen.go | 4 ++-- core/external_info.go | 15 +++------------ core/wire_providers.go | 4 ++-- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/cmd/wire_gen.go b/cmd/wire_gen.go index d7a7e89f..dbef00de 100644 --- a/cmd/wire_gen.go +++ b/cmd/wire_gen.go @@ -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 } diff --git a/core/external_info.go b/core/external_info.go index 288c91f4..52344531 100644 --- a/core/external_info.go +++ b/core/external_info.go @@ -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) { diff --git a/core/wire_providers.go b/core/wire_providers.go index f0ee4f1f..c16f4d1c 100644 --- a/core/wire_providers.go +++ b/core/wire_providers.go @@ -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 }