Skip to content

Commit

Permalink
Songs can now be searched succesfully
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-pierce committed Sep 8, 2021
1 parent ee5f28e commit beed21a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
3 changes: 0 additions & 3 deletions auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ func AuthUser() (*spotify.Client, context.Context) {

// first start an HTTP server
http.HandleFunc("/callback", completeAuth)
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
log.Println("Got request for:", r.URL.String())
})
go func() {
err := http.ListenAndServe(":8080", nil)
if err != nil {
Expand Down
12 changes: 3 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,12 @@ package main
import (
"billboard-scraper/auth"
"billboard-scraper/playlist-builder"
"fmt"
//"billboard-scraper/scraper"
"billboard-scraper/scraper"
)

func main() {
// var songList []string
// songList = scraper.GetSongList()

//fmt.Println(songList)
songList := scraper.GetSongList()

client, ctx := authorizeUser.AuthUser()
fmt.Println(client)
fmt.Println(ctx)
playlist.BuildPlaylist(client, ctx)
playlist.BuildPlaylist(client, ctx, songList)
}
23 changes: 20 additions & 3 deletions playlist-builder/playlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,26 @@ import (
"context"
"fmt"
"github.com/zmb3/spotify/v2"
"log"
)

func BuildPlaylist(client *spotify.Client, ctx context.Context) {
fmt.Println(client)
fmt.Println(ctx)
func BuildPlaylist(client *spotify.Client, ctx context.Context, songList []string) {
user, err := client.CurrentUser(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println("You are logged in as:", user.ID)

result, err := client.Search(ctx, songList[0], spotify.SearchTypeTrack)
if err != nil {
log.Fatal(err)
}

fmt.Println(result.Tracks.Tracks[0].SimpleTrack.URI)

// newPlaylist, err := client.CreatePlaylistForUser(context.Background(), user.ID, "TEST GOLANG", "Test for my golang application", true, false)
// if err != nil {
// log.Fatal(err)
// }
// fmt.Println(newPlaylist)
}

0 comments on commit beed21a

Please sign in to comment.