Skip to content

Commit f6d7252

Browse files
committed
Fix Node 4 compatibility. Fix Spotify queue bug
1 parent fcb5c34 commit f6d7252

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

lib/actions/musicSearch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ function musicSearch(player, values) {
196196
const service = values[0];
197197
const type = values[1];
198198
const term = values[2];
199-
const queueURI = 'x-rincon-queue:' + player.uuid + '#0';
199+
const queueURI = 'x-rincon-queue:' + player.coordinator.uuid + '#0';
200200

201201
if (musicServices.indexOf(service) == -1) {
202202
return Promise.reject('Invalid music service');

lib/music_services/spotifyDef.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ const settings = require('../../settings');
66
var clientId = "";
77
var clientSecret = "";
88

9-
try {
9+
if (settings.spotify) {
1010
clientId = settings.spotify.clientId;
1111
clientSecret = settings.spotify.clientSecret;
12-
} catch(e) {
1312
}
1413

1514
var clientToken = null;
@@ -55,13 +54,17 @@ var toBase64 = (string) => new Buffer(string).toString('base64');
5554

5655
const SPOTIFY_TOKEN_URL = 'https://accounts.spotify.com/api/token';
5756

58-
const mapResponse = ({ access_token, token_type, expires_in }) => ({
59-
accessToken: access_token,
60-
tokenType: token_type,
61-
expiresIn: expires_in,
57+
const mapResponse = (response) => ({
58+
accessToken: response.access_token,
59+
tokenType: response.token_type,
60+
expiresIn: response.expires_in,
6261
});
6362

6463
const getHeaders = () => {
64+
console.log('spotify', clientId, clientSecret)
65+
if (!clientId || !clientSecret) {
66+
throw new Error('You are missing spotify clientId and secret in settings.json! Please read the README for instructions on how to generate and add them');
67+
}
6568
const authString = `${clientId}:${clientSecret}`;
6669
return {
6770
Authorization: `Basic ${toBase64(authString)}`,
@@ -105,7 +108,7 @@ function getTokenHeaders() {
105108
function authenticateService() {
106109
return new Promise((resolve, reject) => {
107110
auth().then((response) => {
108-
const { accessToken } = response;
111+
const accessToken = response.accessToken;
109112
clientToken = accessToken;
110113
resolve();
111114
}).catch(reject);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"json5": "^0.5.1",
1919
"node-static": "~0.7.0",
2020
"request-promise": "~1.0.2",
21-
"sonos-discovery": "https://github.com/jishi/node-sonos-discovery/archive/v1.4.1.tar.gz"
21+
"sonos-discovery": "https://github.com/jishi/node-sonos-discovery/archive/v1.5.1.tar.gz"
2222
},
2323
"engines": {
2424
"node": ">=4.0.0",

0 commit comments

Comments
 (0)