mirror of https://github.com/calzoneman/sync.git
Fix #305
This commit is contained in:
parent
22e2180790
commit
436df375c7
|
@ -1451,6 +1451,14 @@ Channel.prototype.addMedia = function(data, user) {
|
|||
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;
|
||||
self.logger.log("### " + user.name + " queued " +
|
||||
item.media.title);
|
||||
|
|
|
@ -109,9 +109,18 @@ var Getters = {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
var seconds = data.entry.media$group.yt$duration.seconds;
|
||||
var title = data.entry.title.$t;
|
||||
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);
|
||||
} catch(e) {
|
||||
// Gdata version 2 has the rather silly habit of
|
||||
|
|
12
lib/user.js
12
lib/user.js
|
@ -332,6 +332,18 @@ User.prototype.initCallbacks = function () {
|
|||
});
|
||||
} else {
|
||||
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", {
|
||||
source: "library",
|
||||
results: vids
|
||||
|
|
|
@ -861,57 +861,12 @@ Callbacks = {
|
|||
});
|
||||
},
|
||||
|
||||
queueWarn: function (data) {
|
||||
queueMessage(data, "alert-warning");
|
||||
},
|
||||
|
||||
queueFail: function (data) {
|
||||
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 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"));
|
||||
queueMessage(data, "alert-error");
|
||||
},
|
||||
|
||||
setTemp: function(data) {
|
||||
|
|
|
@ -1752,3 +1752,63 @@ function errDialog(err) {
|
|||
div.css("left", x + "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"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue