Add permission for #402; fix a strange jwplayer issue
This commit is contained in:
parent
71114b0060
commit
2b60ab8e10
7 changed files with 116 additions and 36 deletions
|
|
@ -27,6 +27,7 @@ const DEFAULT_PERMISSIONS = {
|
|||
pollvote: -1, // Vote in polls
|
||||
viewhiddenpoll: 1.5, // View results of hidden polls
|
||||
voteskip: -1, // Vote to skip the current video
|
||||
viewvoteskip: 1.5, // View voteskip results
|
||||
mute: 1.5, // Mute other users
|
||||
kick: 1.5, // Kick other users
|
||||
ban: 2, // Ban other users
|
||||
|
|
@ -253,6 +254,10 @@ PermissionsModule.prototype.canVoteskip = function (account) {
|
|||
return this.hasPermission(account, "voteskip");
|
||||
};
|
||||
|
||||
PermissionsModule.prototype.canSeeVoteskipResults = function (actor) {
|
||||
return this.hasPermission(actor, "viewvoteskip");
|
||||
};
|
||||
|
||||
PermissionsModule.prototype.canMute = function (actor) {
|
||||
return this.hasPermission(actor, "mute");
|
||||
};
|
||||
|
|
@ -363,6 +368,7 @@ PermissionsModule.prototype.loadUnregistered = function () {
|
|||
pollvote: -1, // Vote in polls
|
||||
viewhiddenpoll: 1.5, // View results of hidden polls
|
||||
voteskip: -1, // Vote to skip the current video
|
||||
viewvoteskip: 1.5, // View voteskip results
|
||||
playlistlock: 2, // Lock/unlock the playlist
|
||||
leaderctl: 0, // Give/take leader
|
||||
drink: 0, // Use the /d command
|
||||
|
|
|
|||
|
|
@ -93,8 +93,10 @@ VoteskipModule.prototype.sendVoteskipData = function (users) {
|
|||
: 0
|
||||
};
|
||||
|
||||
var perms = this.channel.modules.permissions;
|
||||
|
||||
users.forEach(function (u) {
|
||||
if (u.account.effectiveRank >= 1.5) {
|
||||
if (perms.canSeeVoteskipResults(u)) {
|
||||
u.socket.emit("voteskip", data);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -18,6 +18,31 @@ var Server = require("./server");
|
|||
var Config = require("./config");
|
||||
var ffmpeg = require("./ffmpeg");
|
||||
|
||||
/*
|
||||
* Preference map of quality => youtube formats.
|
||||
* see https://en.wikipedia.org/wiki/Youtube#Quality_and_codecs
|
||||
*
|
||||
* Prefer WebM over MP4, ignore other codecs (e.g. FLV)
|
||||
*/
|
||||
const GOOGLE_PREFERENCE = {
|
||||
"hd1080": [46, 37],
|
||||
"hd720": [45, 22],
|
||||
"large": [44, 59],
|
||||
"medium": [43, 18, 34] // 34 is 360p FLV as a last-ditch
|
||||
};
|
||||
|
||||
const CONTENT_TYPES = {
|
||||
43: "webm",
|
||||
44: "webm",
|
||||
45: "webm",
|
||||
46: "webm",
|
||||
18: "mp4",
|
||||
22: "mp4",
|
||||
37: "mp4",
|
||||
59: "mp4",
|
||||
34: "flv"
|
||||
};
|
||||
|
||||
var urlRetrieve = function (transport, options, callback) {
|
||||
// Catch any errors that crop up along the way of the request
|
||||
// in order to prevent them from reaching the global handler.
|
||||
|
|
@ -720,32 +745,26 @@ var Getters = {
|
|||
videos[parts[0]] = parts[1];
|
||||
});
|
||||
|
||||
/*
|
||||
* Preference map of quality => youtube formats.
|
||||
* see https://en.wikipedia.org/wiki/Youtube#Quality_and_codecs
|
||||
*
|
||||
* Prefer WebM over MP4, ignore other codecs (e.g. FLV)
|
||||
*/
|
||||
const preference = {
|
||||
"hd1080": [46, 37],
|
||||
"hd720": [45, 22],
|
||||
"large": [44, 59],
|
||||
"medium": [43, 18]
|
||||
};
|
||||
|
||||
var direct = {};
|
||||
|
||||
for (var key in preference) {
|
||||
for (var i = 0; i < preference[key].length; i++) {
|
||||
var format = preference[key][i];
|
||||
for (var key in GOOGLE_PREFERENCE) {
|
||||
for (var i = 0; i < GOOGLE_PREFERENCE[key].length; i++) {
|
||||
var format = GOOGLE_PREFERENCE[key][i];
|
||||
|
||||
if (format in videos) {
|
||||
direct[key] = videos[format];
|
||||
direct[key] = {
|
||||
url: videos[format],
|
||||
contentType: CONTENT_TYPES[format]
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(direct).length === 0) {
|
||||
return callback("No valid links could be extracted", null);
|
||||
}
|
||||
|
||||
callback(null, new Media(id, title, seconds, "gd", { gpdirect: direct }));
|
||||
} catch (e) {
|
||||
return callback("Failed to parse Google Docs output", null);
|
||||
|
|
@ -853,25 +872,17 @@ var Getters = {
|
|||
videos[video.format] = video;
|
||||
});
|
||||
|
||||
/*
|
||||
* Preference map of quality => youtube formats.
|
||||
* see https://en.wikipedia.org/wiki/Youtube#Quality_and_codecs
|
||||
*/
|
||||
const preference = {
|
||||
"hd1080": [46, 37],
|
||||
"hd720": [45, 22],
|
||||
"large": [44, 59],
|
||||
"medium": [43, 18]
|
||||
};
|
||||
|
||||
var direct = {};
|
||||
|
||||
for (var key in preference) {
|
||||
for (var i = 0; i < preference[key].length; i++) {
|
||||
var format = preference[key][i];
|
||||
for (var key in GOOGLE_PREFERENCE) {
|
||||
for (var i = 0; i < GOOGLE_PREFERENCE[key].length; i++) {
|
||||
var format = GOOGLE_PREFERENCE[key][i];
|
||||
|
||||
if (format in videos) {
|
||||
direct[key] = videos[format].link;
|
||||
direct[key] = {
|
||||
url: videos[format],
|
||||
contentType: CONTENT_TYPES[format]
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue