aboutsummaryrefslogtreecommitdiff
path: root/backend.go
blob: 9cb42f81636c8bfa5d46ad33f685b0411590dbd8 (plain)
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
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)))
}