This commit is contained in:
calzoneman 2013-11-10 22:26:30 -06:00
parent 22e2180790
commit 436df375c7
5 changed files with 94 additions and 50 deletions

View File

@ -1451,6 +1451,14 @@ Channel.prototype.addMedia = function(data, user) {
return; return;
} }
if (m.restricted) {
user.socket.emit("queueWarn", {
msg: "This video is blocked in the following countries: " +
m.restricted,
link: $util.formatLink(m.id, m.type)
});
}
var item = res.item; var item = res.item;
self.logger.log("### " + user.name + " queued " + self.logger.log("### " + user.name + " queued " +
item.media.title); item.media.title);

View File

@ -109,9 +109,18 @@ var Getters = {
} }
} }
} }
var seconds = data.entry.media$group.yt$duration.seconds; var seconds = data.entry.media$group.yt$duration.seconds;
var title = data.entry.title.$t; var title = data.entry.title.$t;
var media = new Media(id, title, seconds, "yt"); var media = new Media(id, title, seconds, "yt");
if (data.entry.media$group.media$restriction) {
var rest = data.entry.media$group.media$restriction;
if (rest.length > 0) {
if (rest[0].relationship === "deny") {
media.restricted = rest[0].$t;
}
}
}
callback(false, media); callback(false, media);
} catch(e) { } catch(e) {
// Gdata version 2 has the rather silly habit of // Gdata version 2 has the rather silly habit of

View File

@ -332,6 +332,18 @@ User.prototype.initCallbacks = function () {
}); });
} else { } else {
self.channel.search(data.query, function (vids) { self.channel.search(data.query, function (vids) {
if (vids.length === 0) {
var searchfn = InfoGetter.Getters.ytSearch;
searchfn(data.query.split(" "), function (e, vids) {
if (!e) {
self.socket.emit("searchResults", {
source: "yt",
results: vids
});
}
});
return;
}
self.socket.emit("searchResults", { self.socket.emit("searchResults", {
source: "library", source: "library",
results: vids results: vids

View File

@ -861,57 +861,12 @@ Callbacks = {
}); });
}, },
queueWarn: function (data) {
queueMessage(data, "alert-warning");
},
queueFail: function (data) { queueFail: function (data) {
if (!data) queueMessage(data, "alert-error");
data = { link: null };
if (!data.msg || data.msg === true) {
data.msg = "Queue failed. Check your link to make sure it is valid.";
}
var alerts = $(".qfalert");
for (var i = 0; i < alerts.length; i++) {
var al = $(alerts[i]);
var cl = al.clone();
cl.children().remove();
if (cl.text() === data.msg) {
var tag = al.find(".label-important");
if (tag.length > 0) {
var morelinks = al.find(".qflinks");
$("<a/>").attr("href", data.link)
.attr("target", "_blank")
.text(data.link)
.appendTo(morelinks);
$("<br/>").appendTo(morelinks);
var count = parseInt(tag.text().match(/\d+/)[0]) + 1;
tag.text(tag.text().replace(/\d+/, ""+count));
} else {
var tag = $("<span/>")
.addClass("label label-important pull-right pointer")
.text("+ 1 more")
.appendTo(al);
var morelinks = $("<div/>")
.addClass("qflinks")
.appendTo(al)
.hide();
$("<a/>").attr("href", data.link)
.attr("target", "_blank")
.text(data.link)
.appendTo(morelinks);
$("<br/>").appendTo(morelinks);
tag.click(function () {
morelinks.toggle();
});
}
return;
}
}
var text = data.msg;
if (typeof data.link === "string") {
text += "<br><a href='" + data.link + "' target='_blank'>" +
data.link + "</a>";
}
makeAlert("Error", text, "alert-error")
.addClass("span12 qfalert")
.appendTo($("#queuefail"));
}, },
setTemp: function(data) { setTemp: function(data) {

View File

@ -1752,3 +1752,63 @@ function errDialog(err) {
div.css("left", x + "px"); div.css("left", x + "px");
div.css("top", y + "px"); div.css("top", y + "px");
} }
function queueMessage(data, type) {
if (!data)
data = { link: null };
if (!data.msg || data.msg === true) {
data.msg = "Queue failed. Check your link to make sure it is valid.";
}
var ltype = "label-important";
var title = "Error";
if (type === "alert-warning")
ltype = "label-warning";
if (type === "alert-warning")
title = "Warning";
var alerts = $(".qfalert.qf-" + type);
for (var i = 0; i < alerts.length; i++) {
var al = $(alerts[i]);
var cl = al.clone();
cl.children().remove();
if (cl.text() === data.msg) {
var tag = al.find("." + ltype);
if (tag.length > 0) {
var morelinks = al.find(".qflinks");
$("<a/>").attr("href", data.link)
.attr("target", "_blank")
.text(data.link)
.appendTo(morelinks);
$("<br/>").appendTo(morelinks);
var count = parseInt(tag.text().match(/\d+/)[0]) + 1;
tag.text(tag.text().replace(/\d+/, ""+count));
} else {
var tag = $("<span/>")
.addClass("label pull-right pointer " + ltype)
.text("+ 1 more")
.appendTo(al);
var morelinks = $("<div/>")
.addClass("qflinks")
.appendTo(al)
.hide();
$("<a/>").attr("href", data.link)
.attr("target", "_blank")
.text(data.link)
.appendTo(morelinks);
$("<br/>").appendTo(morelinks);
tag.click(function () {
morelinks.toggle();
});
}
return;
}
}
var text = data.msg;
if (typeof data.link === "string") {
text += "<br><a href='" + data.link + "' target='_blank'>" +
data.link + "</a>";
}
makeAlert(title, text, type)
.addClass("span12 qfalert qf-" + type)
.appendTo($("#queuefail"));
}