From 8b4335c18752ce96e452dc232e57695c2fdf6a6d Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Thu, 21 Jul 2022 21:14:14 +0200 Subject: intermediate commit * add dummy backend * enable spotify searching * JS: use let instead of var * improve logging * support adding new songs from search * rename Song.Id to Song.Uri --- dummyBackend.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 dummyBackend.go (limited to 'dummyBackend.go') diff --git a/dummyBackend.go b/dummyBackend.go new file mode 100644 index 0000000..f2eae57 --- /dev/null +++ b/dummyBackend.go @@ -0,0 +1,29 @@ +package main + +import ( + "crypto/sha1" + "encoding/base64" +) + +type DummyBackend struct{} + +func (dummy *DummyBackend) Play(song Song) { +} + +func (dummy *DummyBackend) Pause() { +} + +func (dummy *DummyBackend) Search(keyword string) []Song { + + s := NewDummySong("Dummy Mc Crashtest", "exactly "+keyword) + return []Song{s} +} + +func NewDummySong(title string, artist string) Song { + s := Song{title, artist, "dummy", "", 0, 0, map[string]struct{}{}, map[string]struct{}{}} + h := sha1.New() + h.Write([]byte(title)) + h.Write([]byte(artist)) + s.Uri = base64.URLEncoding.EncodeToString(h.Sum(nil)) + return s +} -- cgit v1.2.3