-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd.go
46 lines (38 loc) · 748 Bytes
/
add.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
package main
import (
"fmt"
"github.com/callebjorkell/rpi-nfc-player/deezer"
"github.com/callebjorkell/rpi-nfc-player/sonos"
log "github.com/sirupsen/logrus"
)
func storeAlbum(id uint64, cardId string) {
a, err := deezer.GetAlbum(fmt.Sprint(id))
if err != nil {
log.Error(err)
return
}
if cardId == "" {
cardId = getCardId()
}
p := sonos.FromAlbum(a, cardId)
db.StoreCard(p)
}
func storePlaylist(id uint64, cardId string) {
p, err := deezer.GetPlaylist(fmt.Sprint(id))
if err != nil {
log.Error(err)
return
}
if cardId == "" {
cardId = getCardId()
}
pl := sonos.FromPlaylist(p, cardId)
db.StoreCard(pl)
}
func getCardId() string {
id, err := readSingleCard()
if err != nil {
log.Fatal(err)
}
return id
}