-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
49 lines (38 loc) · 1020 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"bufio"
"fmt"
"os"
"strings"
"time"
authorizeUser "github.com/mvrsss/go-live-playlist/auth"
playlist "github.com/mvrsss/go-live-playlist/playlist-builder"
search "github.com/mvrsss/go-live-playlist/search-track"
)
var (
trackName string
artistName string
)
func readInput() string {
reader := bufio.NewReader(os.Stdin)
input, err := reader.ReadString('\n')
if err != nil {
fmt.Println("An error occured while reading input. Please try again", err)
return ""
}
input = strings.TrimSuffix(input, "\n")
return input
}
func main() {
// Authorize user for Spotify
client, ctx := authorizeUser.AuthUser()
fmt.Println("Enter song name: ")
trackName = readInput()
fmt.Println("Enter artist name: ")
artistName = readInput()
time.Sleep(1 * time.Second)
uriList := search.SearchTrack(client, ctx, trackName, artistName)
time.Sleep(1 * time.Second)
// Build and create playlist on user's account
playlist.BuildPlaylist(client, ctx, uriList, trackName, artistName)
}