Better error reporting for queue fails (404)

This commit is contained in:
calzoneman 2013-08-01 10:12:22 -04:00
parent 329505de9d
commit 51e48e924d
1 changed files with 26 additions and 9 deletions

View File

@ -91,7 +91,13 @@ var Getters = {
}; };
urlRetrieve(https, options, function (status, data) { urlRetrieve(https, options, function (status, data) {
if(status !== 200) { if(status === 404) {
callback("Video not found", null);
return;
} else if(status === 403) {
callbacK("Private video", null);
return;
} else if(status !== 200) {
callback(true, null); callback(true, null);
return; return;
} }
@ -140,7 +146,13 @@ var Getters = {
}; };
urlRetrieve(https, options, function (status, data) { urlRetrieve(https, options, function (status, data) {
if(status !== 200) { if(status === 404) {
callback("Video not found", null);
return;
} else if(status === 403) {
callbacK("Private video", null);
return;
} else if(status !== 200) {
callback(true, null); callback(true, null);
return; return;
} }
@ -161,7 +173,7 @@ var Getters = {
} }
}); });
}, },
/* dailymotion.com */ /* dailymotion.com */
dm: function (id, callback) { dm: function (id, callback) {
// Dailymotion's API is an example of an API done right // Dailymotion's API is an example of an API done right
@ -189,11 +201,13 @@ var Getters = {
data = JSON.parse(data); data = JSON.parse(data);
var title = data.title; var title = data.title;
var seconds = data.duration; var seconds = data.duration;
if(title === "Deleted video" && seconds === 10) {
callback("Video not found", null);
return;
}
var media = new Media(id, title, seconds, "dm"); var media = new Media(id, title, seconds, "dm");
callback(false, media); callback(false, media);
} catch(e) { } catch(e) {
// TODO See what kinds of errors DM returns
var err = true;
callback(err, null); callback(err, null);
} }
}); });
@ -219,7 +233,10 @@ var Getters = {
}; };
urlRetrieve(https, options, function (status, data) { urlRetrieve(https, options, function (status, data) {
if(status !== 302) { if(status === 404) {
callback("Sound not found", null);
return;
} else if(status !== 302) {
callback(true, null); callback(true, null);
return; return;
} }
@ -260,10 +277,10 @@ var Getters = {
callback(true, null); callback(true, null);
} }
}); });
}); });
}, },
/* livestream.com */ /* livestream.com */
li: function (id, callback) { li: function (id, callback) {
var title = "Livestream.com - " + id; var title = "Livestream.com - " + id;
@ -313,7 +330,7 @@ var Getters = {
var media = new Media(m[1], title, "--:--", "us"); var media = new Media(m[1], title, "--:--", "us");
callback(false, media); callback(false, media);
} }
callback(true, null); callback(true, null);
}); });
}, },