From a878d6551b2e843a782b86af7a8c6f23182ffae8 Mon Sep 17 00:00:00 2001 From: Vibol Hou Date: Thu, 11 Aug 2016 20:25:47 -0700 Subject: [PATCH 1/2] Add maxVolume, switch to node-sonos HEAD, use addSpotify for queuing to fix 500 error --- config.json | 3 ++- index.js | 9 +++++---- package.json | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/config.json b/config.json index d79896c..9b2cfc0 100644 --- a/config.json +++ b/config.json @@ -3,5 +3,6 @@ "standardChannel" : "music", "sonos" : "IP_TO_SONOS", "token" : "SLACK:TOKEN", - "market" : "US" + "market" : "US", + "maxVolume" : 75 } diff --git a/index.js b/index.js index 3978dd4..c0e0ca5 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,7 @@ var Sonos = require('sonos').Sonos var configure = require('./config.json'); var sonos = new Sonos(configure.sonos); var adminChannel = configure.adminChannel; +var maxVolume = configure.maxVolume; var market = configure.market; var standardChannel = configure.standardChannel; var urllibsync = require('urllib-sync'); @@ -218,7 +219,7 @@ function _setVolume(input, channel) { } else { vol = Number(vol); console.log(vol); - if(vol > 55) { + if(vol > maxVolume) { slack.sendMessage('You also could have tinnitus _(say: tih-neye-tus)_', channel.id); } else { sonos.setVolume(vol, function(err, data) { @@ -478,7 +479,7 @@ function _append(input, channel) { if (state === 'stopped') { // Ok, lets start again.. NO Flush //Add the track to playlist... - sonos.addSpotifyQueue(spid, function (err, res) { + sonos.addSpotify(spid, function (err, res) { var message = ''; if(res) { var queueLength = res[0].FirstTrackNumberEnqueued; @@ -590,7 +591,7 @@ function _add(input, channel) { if(flushed) { slack.sendMessage('Clean slate.. Let´s make it better this time!!', channel.id); //Then add the track to playlist... - sonos.addSpotifyQueue(spid, function (err, res) { + sonos.addSpotify(spid, function (err, res) { var message = ''; if(res) { var queueLength = res[0].FirstTrackNumberEnqueued; @@ -617,7 +618,7 @@ function _add(input, channel) { }); } else if (state === 'playing') { //Add the track to playlist... - sonos.addSpotifyQueue(spid, function (err, res) { + sonos.addSpotify(spid, function (err, res) { var message = ''; if(res) { var queueLength = res[0].FirstTrackNumberEnqueued; diff --git a/package.json b/package.json index 37b2cf0..8e9cd3f 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "dependencies": { "htmlencode": "0.0.4", "@slack/client": "^3.5.1", - "sonos": "git+https://github.com/bencevans/node-sonos.git#bfb995610c8aa20bda09e370b0f5d31ba0caa6a0", + "sonos": "git+https://github.com/bencevans/node-sonos.git#master", "urlencode": "^1.1.0", "urllib-sync": "^1.1.2" } From feff979ea0d9693c0ab7d19ae170ea655491a6d1 Mon Sep 17 00:00:00 2001 From: Vibol Hou Date: Thu, 11 Aug 2016 20:30:24 -0700 Subject: [PATCH 2/2] Add a few more TODOs --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 325a0bc..f335e9d 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,10 @@ List of commands (just type help in the channel) * Now playing. Announce when starting a new song. * When asking for "Stat" show most played songs and most active users. * When local playlist is empty -> fallback and start playing "$playlist", i.e. Spotify topp 100. +* Limit consecutive song additions by non-admin +* Restrict songs already in the queue +* Delete range of songs from queue +* Vote to flush entire queue *DONE*