forked from minchao/go-apple-music
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (32 loc) · 718 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
package main
import (
"context"
"flag"
"fmt"
"os"
"github.com/minchao/go-apple-music"
)
func usage() {
fmt.Fprintln(os.Stderr, `Usage: simple [options]`)
flag.PrintDefaults()
}
func main() {
var token string
flag.StringVar(&token, "t", "", "Apple Music API Token")
flag.Usage = usage
flag.Parse()
if len(os.Args) < 2 {
flag.Usage()
os.Exit(1)
}
ctx := context.Background()
tp := applemusic.Transport{Token: token}
client := applemusic.NewClient(tp.Client())
// Fetch all the storefronts in alphabetical order
storefronts, _, err := client.Storefront.GetAll(ctx, nil)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
fmt.Fprintf(os.Stdout, "result: %+v\n", storefronts)
}