Пример #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)
		}
	}
}
Пример #2
0
Файл: rest.go Проект: andynu/rfk
func skipHandler(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Access-Control-Allow-Origin", "*")
	api.Skip()
	fmt.Fprintf(w, "ok")
}
Пример #3
0
Файл: rpc.go Проект: andynu/rfk
func (t *Player) Skip(in In, out *Out) error {
	log.Println("rpc: skip")
	api.Skip()
	return nil
}