Handle non-album/track ids in GPM, 404 xbox
This commit is contained in:
parent
b3ca20570e
commit
15712f9482
4 changed files with 14 additions and 3 deletions
|
@ -29,6 +29,10 @@ module.exports.parseUrl = function(url) {
|
||||||
var artist = decodeURIComponent(parts[3]);
|
var artist = decodeURIComponent(parts[3]);
|
||||||
var album = decodeURIComponent(parts[4]);
|
var album = decodeURIComponent(parts[4]);
|
||||||
|
|
||||||
|
if (type != "album" && type != "track") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (id.length > 0) {
|
if (id.length > 0) {
|
||||||
return {id: id, type: type};
|
return {id: id, type: type};
|
||||||
} else {
|
} else {
|
||||||
|
@ -39,6 +43,7 @@ module.exports.parseUrl = function(url) {
|
||||||
var type = matches[1][0] == "T" ? "track" : "album";
|
var type = matches[1][0] == "T" ? "track" : "album";
|
||||||
return module.exports.lookupId(matches[1], type);
|
return module.exports.lookupId(matches[1], type);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +110,7 @@ module.exports.search = function(data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return pm.searchAsync(query, 5).then(function(result) {
|
return pm.searchAsync(query, 5).then(function(result) {
|
||||||
|
|
||||||
if (!result.entries) {
|
if (!result.entries) {
|
||||||
var matches = album.match(/^[^\(\[]+/);
|
var matches = album.match(/^[^\(\[]+/);
|
||||||
if (matches[0] && matches[0] != album) {
|
if (matches[0] && matches[0] != album) {
|
||||||
|
|
|
@ -72,6 +72,8 @@ module.exports.lookupId = function(id, type) {
|
||||||
var path = "/" + id + "/lookup";
|
var path = "/" + id + "/lookup";
|
||||||
return request.get(apiRoot + path).set("Authorization", "Bearer " + access_token).promise().then(function(res) {
|
return request.get(apiRoot + path).set("Authorization", "Bearer " + access_token).promise().then(function(res) {
|
||||||
return formatResponse(res);
|
return formatResponse(res);
|
||||||
|
}, function(res) {
|
||||||
|
return {service: "xbox"};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -92,6 +94,8 @@ module.exports.search = function(data) {
|
||||||
var path = "/music/search?q=" + encodeURIComponent(query) + "&filters=" + type + "s";
|
var path = "/music/search?q=" + encodeURIComponent(query) + "&filters=" + type + "s";
|
||||||
return request.get(apiRoot + path).set("Authorization", "Bearer " + access_token).promise().then(function(res) {
|
return request.get(apiRoot + path).set("Authorization", "Bearer " + access_token).promise().then(function(res) {
|
||||||
return formatResponse(res);
|
return formatResponse(res);
|
||||||
|
}, function(res) {
|
||||||
|
return {service: "xbox"};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,9 +46,9 @@ module.exports = function(req, res, next) {
|
||||||
error = new Error("An unexpected error happenend");
|
error = new Error("An unexpected error happenend");
|
||||||
error.status = 500;
|
error.status = 500;
|
||||||
next(error);
|
next(error);
|
||||||
} else if (error.status == 404){
|
|
||||||
res.json({error:{message:"No match found for url"}});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
res.json({error:{message:"No match found for url"}});
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,6 +133,7 @@ module.exports = React.createClass({
|
||||||
getShares();
|
getShares();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Temporary until websockets implementation
|
||||||
this.state.interval = setInterval(function() {
|
this.state.interval = setInterval(function() {
|
||||||
if (!complete) {
|
if (!complete) {
|
||||||
getShares();
|
getShares();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue