aboutsummaryrefslogtreecommitdiff
path: root/dummyBackend.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2022-07-21 21:14:14 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2022-07-21 21:14:14 +0200
commit8b4335c18752ce96e452dc232e57695c2fdf6a6d (patch)
treee191e079b607126a890a0bf1498a3f8167a8204e /dummyBackend.go
parenta14ffdfc999abd76c2d9937e778c932a457be08f (diff)
downloadWRMS-8b4335c18752ce96e452dc232e57695c2fdf6a6d.tar.gz
WRMS-8b4335c18752ce96e452dc232e57695c2fdf6a6d.zip
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
Diffstat (limited to 'dummyBackend.go')
-rw-r--r--dummyBackend.go29
1 files changed, 29 insertions, 0 deletions
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
+}