Skip to content

Commit

Permalink
Do not use auth client when searching
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiofalci committed Jan 27, 2017
1 parent 16b630b commit 9d6094e
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions spotify/spotify_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

func (spotify *Spotify) shutdownSpotify() {
spotify.session.Logout()
spotify.session.Close()
spotify.initCache()
spotify.events.ShutdownEngine()
}
Expand Down Expand Up @@ -72,7 +73,8 @@ func (spotify *Spotify) search(query string) {

playlist := sconsify.InitSearchPlaylist(name, name, func(playlist *sconsify.Playlist) {
options := createWebSpotifyOptions(50, playlist.Tracks())
if searchResult, err := spotify.getWebApiClient().SearchOpt(query, webspotify.SearchTypeTrack, options); err == nil {
// TODO use spotify.client while still token valid, then switch to Default one
if searchResult, err := webspotify.DefaultClient.SearchOpt(query, webspotify.SearchTypeTrack, options); err == nil {
numberOfTracks := len(searchResult.Tracks.Tracks)
infrastructure.Debugf("Search '%v' returned %v track(s)", query, numberOfTracks)
for _, track := range searchResult.Tracks.Tracks {
Expand Down Expand Up @@ -102,13 +104,6 @@ func checkAlias(query string) string {
return query
}

func (spotify *Spotify) getWebApiClient() *webspotify.Client {
if spotify.client != nil {
return spotify.client
}
return webspotify.DefaultClient
}

func (spotify *Spotify) pause() {
if spotify.currentTrack != nil {
if spotify.paused {
Expand Down

0 comments on commit 9d6094e

Please sign in to comment.