Fix clean; minor error message fixes

This commit is contained in:
calzoneman 2013-10-07 00:10:16 -05:00
parent 7d862cac60
commit 718a70bc60
4 changed files with 28 additions and 19 deletions

View file

@ -1,3 +1,9 @@
Mon Oct 07 00:08 2013 CDT
* lib/playlist.js: Fix /clean not behaving properly (actually was a
consequence of the remove() function)
* lib/get-info.js: Send more specific error messages
* www/assets/js/callbacks.js: Minor fix to the queueFail callback
Sun Oct 06 01:42 2013 CDT Sun Oct 06 01:42 2013 CDT
* lib/channel.js, www/assets/js/callbacks.js: Include the link that * lib/channel.js, www/assets/js/callbacks.js: Include the link that
failed with the queueFail packet. Clicking the "+ n more" tag failed with the queueFail packet. Clicking the "+ n more" tag

View file

@ -120,7 +120,7 @@ module.exports = function (Server) {
if(m === null) if(m === null)
m = buffer.match(/<code>([^<]+)<\/code>/); m = buffer.match(/<code>([^<]+)<\/code>/);
var err = true; var err = e;
if(m) { if(m) {
if(m[1] === "too_many_recent_calls") { if(m[1] === "too_many_recent_calls") {
err = "YouTube is throttling the server right "+ err = "YouTube is throttling the server right "+
@ -161,7 +161,7 @@ module.exports = function (Server) {
urlRetrieve(https, options, function (status, data) { urlRetrieve(https, options, function (status, data) {
if(status !== 200) { if(status !== 200) {
callback(true, null); callback("YTv3: HTTP " + status, null);
return; return;
} }
@ -170,7 +170,7 @@ module.exports = function (Server) {
// I am a bit disappointed that the API v3 just doesn't // I am a bit disappointed that the API v3 just doesn't
// return anything in any error case // return anything in any error case
if(data.pageInfo.totalResults !== 1) { if(data.pageInfo.totalResults !== 1) {
callback(true, null); callback("Video not found", null);
return; return;
} }
@ -185,7 +185,7 @@ module.exports = function (Server) {
var media = new Media(id, title, seconds, "yt"); var media = new Media(id, title, seconds, "yt");
callback(false, media); callback(false, media);
} catch(e) { } catch(e) {
callback(true, media); callback(e, null);
} }
}); });
}, },
@ -231,7 +231,7 @@ module.exports = function (Server) {
callback("API failure", null); callback("API failure", null);
return; return;
} else if(status !== 200) { } else if(status !== 200) {
callback(true, null); callback("YTPlaylist HTTP " + status, null);
} }
try { try {
@ -257,7 +257,7 @@ module.exports = function (Server) {
Getters["yp"](id, callback, links[i].href); Getters["yp"](id, callback, links[i].href);
} }
} catch(e) { } catch(e) {
callback(true, null); callback(e, null);
} }
}); });
@ -286,7 +286,7 @@ module.exports = function (Server) {
urlRetrieve(https, options, function (status, data) { urlRetrieve(https, options, function (status, data) {
if(status !== 200) { if(status !== 200) {
callback(true, null); callback("YTSearch HTTP " + status, null);
return; return;
} }
@ -308,7 +308,7 @@ module.exports = function (Server) {
callback(false, vids); callback(false, vids);
} catch(e) { } catch(e) {
callback(true, null); callback(e, null);
} }
}); });
}, },
@ -342,7 +342,7 @@ module.exports = function (Server) {
callback("API failure", null); callback("API failure", null);
return; return;
} else if(status !== 200) { } else if(status !== 200) {
callback(true, null); callback("YTv2 HTTP " + status, null);
return; return;
} }
@ -354,7 +354,7 @@ module.exports = function (Server) {
var media = new Media(id, title, seconds, "vi"); var media = new Media(id, title, seconds, "vi");
callback(false, media); callback(false, media);
} catch(e) { } catch(e) {
var err = true; var err = e;
if(buffer.match(/not found/)) if(buffer.match(/not found/))
err = "Video not found"; err = "Video not found";
@ -388,8 +388,11 @@ module.exports = function (Server) {
}; };
urlRetrieve(https, options, function (status, data) { urlRetrieve(https, options, function (status, data) {
if(status !== 200) { if (status === 404) {
callback(true, null); callback("Video not found", null);
return;
} else if (status !== 200) {
callback("DM HTTP " + status, null);
return; return;
} }
@ -444,7 +447,7 @@ module.exports = function (Server) {
callback("API failure", null); callback("API failure", null);
return; return;
} else if(status !== 302) { } else if(status !== 302) {
callback(true, null); callback("SC HTTP " + status, null);
return; return;
} }
@ -453,7 +456,7 @@ module.exports = function (Server) {
data = JSON.parse(data); data = JSON.parse(data);
track = data.location; track = data.location;
} catch(e) { } catch(e) {
callback(true, null); callback(e, null);
return; return;
} }
@ -469,7 +472,7 @@ module.exports = function (Server) {
// I want to get off async's wild ride // I want to get off async's wild ride
urlRetrieve(https, options2, function (status, data) { urlRetrieve(https, options2, function (status, data) {
if(status !== 200) { if(status !== 200) {
callback(true, null); callback("SC HTTP " + status, null);
return; return;
} }
@ -481,7 +484,7 @@ module.exports = function (Server) {
var media = new Media(id, title, seconds, "sc"); var media = new Media(id, title, seconds, "sc");
callback(false, media); callback(false, media);
} catch(e) { } catch(e) {
callback(true, null); callback(e, null);
} }
}); });
@ -554,7 +557,7 @@ module.exports = function (Server) {
urlRetrieve(http, options, function (status, data) { urlRetrieve(http, options, function (status, data) {
if(status !== 200) { if(status !== 200) {
callback(true, null); callback("Ustream HTTP " + status, null);
return; return;
} }

View file

@ -222,7 +222,7 @@ Playlist.prototype.remove = function (uid) {
var item = self.items.find(uid); var item = self.items.find(uid);
if (item && self.items.remove(uid)) { if (item && self.items.remove(uid)) {
if (item === self.current) { if (item === self.current) {
setImmediate(function () { self._next(); }); self._next();
} }
return true; return true;
} else { } else {

View file

@ -806,7 +806,7 @@ Callbacks = {
if (!data) if (!data)
data = { link: null }; data = { link: null };
if (!data.msg || data.msg === true) { if (!data.msg || data.msg === true) {
data = "Queue failed. Check your link to make sure it is valid."; data.msg = "Queue failed. Check your link to make sure it is valid.";
} }
var alerts = $(".qfalert"); var alerts = $(".qfalert");
for (var i = 0; i < alerts.length; i++) { for (var i = 0; i < alerts.length; i++) {