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
|
@ -28,7 +28,11 @@ module.exports.parseUrl = function(url) {
|
|||
var id = parts[2];
|
||||
var artist = decodeURIComponent(parts[3]);
|
||||
var album = decodeURIComponent(parts[4]);
|
||||
|
||||
|
||||
if (type != "album" && type != "track") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (id.length > 0) {
|
||||
return {id: id, type: type};
|
||||
} else {
|
||||
|
@ -39,6 +43,7 @@ module.exports.parseUrl = function(url) {
|
|||
var type = matches[1][0] == "T" ? "track" : "album";
|
||||
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) {
|
||||
|
||||
if (!result.entries) {
|
||||
var matches = album.match(/^[^\(\[]+/);
|
||||
if (matches[0] && matches[0] != album) {
|
||||
|
|
|
@ -72,6 +72,8 @@ module.exports.lookupId = function(id, type) {
|
|||
var path = "/" + id + "/lookup";
|
||||
return request.get(apiRoot + path).set("Authorization", "Bearer " + access_token).promise().then(function(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";
|
||||
return request.get(apiRoot + path).set("Authorization", "Bearer " + access_token).promise().then(function(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.status = 500;
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -133,6 +133,7 @@ module.exports = React.createClass({
|
|||
getShares();
|
||||
}
|
||||
|
||||
// Temporary until websockets implementation
|
||||
this.state.interval = setInterval(function() {
|
||||
if (!complete) {
|
||||
getShares();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue