aboutsummaryrefslogtreecommitdiff
path: root/backend.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2022-12-23 08:51:37 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2022-12-23 08:51:37 +0100
commitb7f5ed4e5fcb3b51636a9dad79e7e80f7ebbb102 (patch)
tree1a8c53db5e7fa34f683c8a0afcb8e33ff104b0a7 /backend.go
parent97a9b0e75a57c6b55bab8c50827f5ba4b896fd95 (diff)
downloadWRMS-b7f5ed4e5fcb3b51636a9dad79e7e80f7ebbb102.tar.gz
WRMS-b7f5ed4e5fcb3b51636a9dad79e7e80f7ebbb102.zip
implement local storage backendv0.0.2-alpha
The 'local' backend is able to serve the music from a path specified by '-server-music-dir'. Add command line options to select the server port as well as a list of backends.
Diffstat (limited to 'backend.go')
-rw-r--r--backend.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/backend.go b/backend.go
new file mode 100644
index 0000000..9cb42f8
--- /dev/null
+++ b/backend.go
@@ -0,0 +1,29 @@
+package main
+
+import (
+ "crypto/sha1"
+ "encoding/base64"
+)
+
+type Backend interface {
+ Play(song *Song, player *Player)
+ Search(keyword string) []Song
+}
+
+type DummyBackend struct{}
+
+func (dummy *DummyBackend) Play(song *Song, player *Player) {
+}
+
+func (dummy *DummyBackend) Search(keyword string) []Song {
+
+ s := NewDummySong("Dummy Mc Crashtest", "exactly "+keyword)
+ return []Song{s}
+}
+
+func NewDummySong(title, artist string) Song {
+ h := sha1.New()
+ h.Write([]byte(title))
+ h.Write([]byte(artist))
+ return NewSong(title, artist, "dummy", base64.URLEncoding.EncodeToString(h.Sum(nil)))
+}