diff options
Diffstat (limited to 'backend.go')
| -rw-r--r-- | backend.go | 29 |
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))) +} |
