diff --git a/lib/channel.js b/lib/channel.js
index a7789afc..2563917b 100644
--- a/lib/channel.js
+++ b/lib/channel.js
@@ -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);
diff --git a/lib/get-info.js b/lib/get-info.js
index 7dc0ce63..ccb14eb2 100644
--- a/lib/get-info.js
+++ b/lib/get-info.js
@@ -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
diff --git a/lib/user.js b/lib/user.js
index a6a3af32..07b56f43 100644
--- a/lib/user.js
+++ b/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
diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js
index c1c5d7b0..0b01b5e2 100644
--- a/www/assets/js/callbacks.js
+++ b/www/assets/js/callbacks.js
@@ -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");
- $("").attr("href", data.link)
- .attr("target", "_blank")
- .text(data.link)
- .appendTo(morelinks);
- $("
").appendTo(morelinks);
- var count = parseInt(tag.text().match(/\d+/)[0]) + 1;
- tag.text(tag.text().replace(/\d+/, ""+count));
- } else {
- var tag = $("")
- .addClass("label label-important pull-right pointer")
- .text("+ 1 more")
- .appendTo(al);
- var morelinks = $("