-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (40 loc) · 819 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
50
51
package main
import (
"flag"
"fmt"
"os"
"github.com/justinwalz/golang-soundcloud/soundcloud"
)
func main() {
var client = flag.String("c", "", "soundcloud client id")
var uid = flag.Uint64("u", 0, "soundcloud user id")
var debug = flag.Bool("d", false, "debug")
flag.Parse()
if *client == "" {
error("client id required")
}
if *uid == 0 {
error("user id required")
}
unauthenticatedAPI := &soundcloud.Api{
ClientId: *client,
}
tracks, err := unauthenticatedAPI.User(*uid).AllFavorites()
if err != nil {
if *debug {
panic(err)
}
os.Exit(1)
}
for _, track := range tracks {
fmt.Println(track.PermalinkUrl)
}
}
func printUsage() {
fmt.Println("usage: slim -c <client-id> -u <user-id>")
}
func error(i interface{}) {
printUsage()
fmt.Printf("error: %v\n", i)
os.Exit(1)
}