Exemple #1
0
func Listener() {
	reader := bufio.NewReader(os.Stdin)
	for {
		text, _ := reader.ReadString('\n')
		text = strings.TrimSuffix(text, "\n")
		args := strings.Split(text, " ")
		command := args[0]
		switch command {
		case "n":
			log.Printf("cmd: n - Next (no punishment)")
			api.SkipNoPunish()

		case "s":
			log.Printf("cmd: s - Skip")
			api.Skip()

		case "p":
			log.Printf("cmd: p - PlayPause")
			api.PlayPause()

		case "r":
			log.Printf("cmd: r - Reward")
			api.Reward()

		case "search":
			term := strings.Join(args[1:], " ")
			log.Printf("cmd: search - %q", term)
			songs := api.Search(term)
			printSearchResults(term, songs)

		case "request":
			term := strings.Join(args[1:], " ")
			log.Printf("cmd: request - %q", term)
			songs := api.SearchRequest(term)
			fmt.Printf("Requested %d songs\n", len(songs))

		case "taglast":
			tag := strings.Join(args[1:], " ")
			log.Printf("cmd: tag last song - %q", tag)
			api.TagLastSong(tag)

		case "tag":
			tag := strings.Join(args[1:], " ")
			log.Printf("cmd: tag current song - %q", tag)
			api.TagCurrentSong(tag)

		case "clear":
			log.Printf("cmd: clear request")
			api.ClearRequests()
			fmt.Printf("Requests Cleared\n")

		default:
			log.Printf("cmd: %q - unknown command", text)
		}
	}
}
Exemple #2
0
func nextHandler(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Access-Control-Allow-Origin", "*")
	api.SkipNoPunish()
	fmt.Fprintf(w, "ok")
}
Exemple #3
0
func (t *Player) SkipNoPunish(in In, out *Out) error {
	log.Println("rpc: skip (no punish)")
	api.SkipNoPunish()
	return nil
}