Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

if has nix; then
use flake --update-input nixpkgs
use flake
fi

dotenv_if_exists
Expand Down
2 changes: 1 addition & 1 deletion berrymotes
Submodule berrymotes updated 51 files
+6 −6 emotescraper/androidscrape.py
+2 −2 emotescraper/bmscraper/downloadjob.py
+1 −1 emotescraper/bmscraper/emote_processors/abstract_emotes_processor.py
+7 −7 emotescraper/bmscraper/emote_processors/android_emotes_processor.py
+4 −1 emotescraper/bmscraper/emote_processors/apngcheck.py
+3 −3 emotescraper/bmscraper/emote_processors/basic_emotes_processor.py
+40 −23 emotescraper/bmscraper/scraper.py
+39 −0 emotescraper/data.py
+1 −0 emotescraper/legacy_css/BTLoungeLoungeLounge.css
+0 −0 emotescraper/legacy_css/GuntherMotes.css
+1 −0 emotescraper/legacy_css/HeartsEmoteEmporium.css
+1 −0 emotescraper/legacy_css/SaphkeyEmoteSub.css
+1 −0 emotescraper/legacy_css/antisonicmotes.css
+1 −0 emotescraper/legacy_css/bloomjackquisition.css
+1 −0 emotescraper/legacy_css/clopclop.css
+1 −0 emotescraper/legacy_css/clopmotes.css
+1 −0 emotescraper/legacy_css/codex_of_wisdom.css
+1 −0 emotescraper/legacy_css/dashiemotes.css
+1 −0 emotescraper/legacy_css/dinkymotes.css
+1 −0 emotescraper/legacy_css/flitter.css
+1 −0 emotescraper/legacy_css/kitsemotediary.css
+1 −0 emotescraper/legacy_css/lunanet.css
+1 −0 emotescraper/legacy_css/marmemotes2.css
+1 −0 emotescraper/legacy_css/mlas1animotes.css
+1 −0 emotescraper/legacy_css/mlpaprilfools2014.css
+1 −0 emotescraper/legacy_css/molestia.css
+1 −0 emotescraper/legacy_css/multihoofdrinking2.css
+1 −0 emotescraper/legacy_css/mylittlealcoholic.css
+1 −0 emotescraper/legacy_css/mylittleayrl.css
+1 −0 emotescraper/legacy_css/mylittlecombiners.css
+1 −0 emotescraper/legacy_css/mylittlegooglyeyes.css
+1 −0 emotescraper/legacy_css/mylittlekitchen.css
+1 −0 emotescraper/legacy_css/mylittlensfw.css
+1 −0 emotescraper/legacy_css/mylittlescoots.css
+1 −0 emotescraper/legacy_css/mylittlestartrek.css
+1 −0 emotescraper/legacy_css/mylittlewtf.css
+1 −0 emotescraper/legacy_css/nlaqemotes.css
+1 −0 emotescraper/legacy_css/nolifemotes.css
+1 −0 emotescraper/legacy_css/ponyanarchism.css
+1 −0 emotescraper/legacy_css/savethebtmotes2.css
+1 −0 emotescraper/legacy_css/shipgirlemotes.css
+1 −0 emotescraper/legacy_css/shittyemotes.css
+1 −0 emotescraper/legacy_css/spanishmeerkat.css
+1 −0 emotescraper/legacy_css/squalomotes.css
+1 −0 emotescraper/legacy_css/stalliongrad.css
+1 −0 emotescraper/legacy_css/tbpimagedump.css
+1 −0 emotescraper/legacy_css/tbpimagedump2.css
+1 −0 emotescraper/legacy_css/thebestpony.css
+1 −1 emotescraper/make_v2.py
+1 −1 emotescraper/requirements.txt
+6 −4 emotescraper/scrape.py
9 changes: 9 additions & 0 deletions docker/node/modules/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,12 @@ exports.isUrl = function(maybeUrl) {
return false;
}
};

exports.tryDecodeURIComponent = function(str) {
try {
return decodeURIComponent(str);
} catch (err) {
console.warn('Ignored:', err);
return str;
}
};
19 changes: 18 additions & 1 deletion docker/node/modules/utils.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { expect } = require("chai");

const { parseFormat, parseRawFileUrl } = require("./utils");
const { parseFormat, parseRawFileUrl, tryDecodeURIComponent } = require("./utils");

describe("parseFormat", function() {
it("parses: left {middle} right", function() {
Expand Down Expand Up @@ -117,3 +117,20 @@ describe("parseRawFileUrl", function() {
expect(ret).to.be.null;
});
});

describe("tryDecodeURIComponent", function() {
it("leaves non-encoded string untouched", function() {
const ret = tryDecodeURIComponent("foobar");
expect(ret).to.equal("foobar");
});

it("decodes an encoded string", function() {
const ret = tryDecodeURIComponent("Any%25%20Speedrun");
expect(ret).to.equal("Any% Speedrun");
});

it("doesn't throw on invalid encoding", function() {
const ret = tryDecodeURIComponent("Any% Speedrun");
expect(ret).to.equal("Any% Speedrun");
});
});
34 changes: 17 additions & 17 deletions docker/node/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { sanitizeManifest } = require("./modules/playlist");
const { DefaultLog, events, levels, consoleLogger, createStreamLogger } = require("./modules/log");
const { DatabaseService } = require("./modules/database");
const { SessionService, getSocketName, userTypes } = require("./modules/sessions");
const { parseRawFileUrl } = require("./modules/utils");
const { parseRawFileUrl, tryDecodeURIComponent } = require("./modules/utils");
const { EventServer } = require("./modules/event-server");
const fetchYoutubeVideoInfo = require("youtube-info");

Expand Down Expand Up @@ -730,13 +730,13 @@ function getCommand(msg) {
function handleNewVideoChange() {
DefaultLog.info(events.EVENT_VIDEO_CHANGE,
"changed video to {videoTitle}",
{ videoTitle: decodeURI(SERVER.ACTIVE.videotitle) });
{ videoTitle: tryDecodeURIComponent(SERVER.ACTIVE.videotitle) });


eventServer.emit('videoChange', {
id: SERVER.ACTIVE.videoid,
length: SERVER.ACTIVE.videolength,
title: decodeURI(SERVER.ACTIVE.videotitle),
title: tryDecodeURIComponent(SERVER.ACTIVE.videotitle),
type: SERVER.ACTIVE.videotype,
volat: SERVER.ACTIVE.volat
});
Expand Down Expand Up @@ -876,7 +876,7 @@ function setVideoVolatile(socket, pos, isVolat) {

DefaultLog.info(events.EVENT_ADMIN_SET_VOLATILE,
"{mod} set {title} to {status}",
{ mod: getSocketName(socket), type: "playlist", title: decodeURIComponent(elem.videotitle), status: isVolat ? "volatile" : "not volatile" });
{ mod: getSocketName(socket), type: "playlist", title: tryDecodeURIComponent(elem.videotitle), status: isVolat ? "volatile" : "not volatile" });

io.sockets.emit("setVidVolatile", {
pos: pos,
Expand Down Expand Up @@ -1431,12 +1431,12 @@ function delVideo(video, sanity, socket) {

DefaultLog.info(events.EVENT_ADMIN_DELETED_VIDEO,
"{mod} deleted {title}",
{ mod: getSocketName(socket), type: "playlist", title: decodeURIComponent(node.videotitle) });
{ mod: getSocketName(socket), type: "playlist", title: tryDecodeURIComponent(node.videotitle) });

} catch (e) {
DefaultLog.error(events.EVENT_ADMIN_DELETED_VIDEO,
"{mod} could not delete {title}",
{ mod: getSocketName(socket), type: "playlist", title: decodeURIComponent(node.videotitle) }, e);
{ mod: getSocketName(socket), type: "playlist", title: tryDecodeURIComponent(node.videotitle) }, e);
}
}

Expand Down Expand Up @@ -1602,7 +1602,7 @@ function _addVideoVimeo(socket, data, meta, path, successCallback, failureCallba
rawAddVideo({
pos: pos,
videoid: jdata.id || jdata.video_id,
videotitle: encodeURI(jdata.title),
videotitle: encodeURIComponent(jdata.title),
videolength: jdata.duration,
videotype: "vimeo",
who: meta.nick,
Expand Down Expand Up @@ -1797,7 +1797,7 @@ function addVideoYT(socket, data, meta, successCallback, failureCallback) {
rawAddVideo({
pos: pos,
videoid: videoid,
videotitle: encodeURI(formattedTitle),
videotitle: encodeURIComponent(formattedTitle),
videolength: formattedTime,
videotype: "yt",
who: meta.nick,
Expand Down Expand Up @@ -1836,7 +1836,7 @@ function addVideoYT(socket, data, meta, successCallback, failureCallback) {
rawAddVideo({
pos: pos,
videoid: videoid,
videotitle: encodeURI(title),
videotitle: encodeURIComponent(title),
videolength: duration,
videotype: "yt",
who: meta.nick,
Expand Down Expand Up @@ -1958,7 +1958,7 @@ async function addVideoSoundCloud(socket, data, meta, successCallback, failureCa
pos: SERVER.PLAYLIST.length,
// Don't collide with vimeo
videoid: 'SC' + jdata.id,
videotitle: encodeURI(jdata.user.username + " - " + jdata.title),
videotitle: encodeURIComponent(jdata.user.username + " - " + jdata.title),
// soundcloud is millis
videolength: jdata.duration / 1000,
videotype: "soundcloud",
Expand Down Expand Up @@ -2080,7 +2080,7 @@ function addVideoDash(socket, data, meta, successCallback, failureCallback) {
if (meta.type <= 0) { volat = true; }
if (volat === undefined) { volat = false; }
const parts = videoid.split('/');
const videoTitle = data.videotitle ? encodeURI(data.videotitle) : parts[parts.length - 1];
const videoTitle = data.videotitle ? encodeURIComponent(data.videotitle) : parts[parts.length - 1];
rawAddVideo({
pos: SERVER.PLAYLIST.length,
videoid: videoid,
Expand Down Expand Up @@ -2163,7 +2163,7 @@ function addVideoTwitch(socket, data, meta, successCallback, failureCallback) {
rawAddVideo({
pos: SERVER.PLAYLIST.length,
videoid: 'videos/' + videoid,
videotitle: encodeURI(response.title),
videotitle: encodeURIComponent(response.title),
videolength: parseDuration(response.duration),
videotype: "twitch",
who: meta.nick,
Expand All @@ -2188,7 +2188,7 @@ function addVideoTwitch(socket, data, meta, successCallback, failureCallback) {
rawAddVideo({
pos: SERVER.PLAYLIST.length,
videoid: response.broadcaster_login,
videotitle: encodeURI(response.display_name),
videotitle: encodeURIComponent(response.display_name),
videolength: 0,
videotype: "twitch",
who: meta.nick,
Expand Down Expand Up @@ -2220,7 +2220,7 @@ function addVideoTwitchClip(socket, data, meta, successCallback, failureCallback
rawAddVideo({
pos: SERVER.PLAYLIST.length,
videoid: response.id,
videotitle: encodeURI(response.title),
videotitle: encodeURIComponent(response.title),
videolength: Math.ceil(response.duration),
videotype: "twitchclip",
who: meta.nick,
Expand Down Expand Up @@ -2270,7 +2270,7 @@ function addVideoDailymotion(socket, data, meta, successCallback, failureCallbac
rawAddVideo({
pos: SERVER.PLAYLIST.length,
videoid: videoId,
videotitle: encodeURI(response.title),
videotitle: encodeURIComponent(response.title),
videolength: response.duration,
videotype: "dm",
who: meta.nick,
Expand Down Expand Up @@ -2458,7 +2458,7 @@ io.sockets.on('connection', function (ioSocket) {
return;
}

const pattern = '%' + encodeURI(data.search).replace(/%/g, '\\%') + '%';
const pattern = '%' + encodeURIComponent(data.search).replace(/%/g, '\\%') + '%';
const { result } = await databaseService.query`
SELECT
*
Expand Down Expand Up @@ -2774,7 +2774,7 @@ io.sockets.on('connection', function (ioSocket) {

DefaultLog.info(events.EVENT_ADMIN_MOVED_VIDEO,
"{mod} moved {title}",
{ mod: getSocketName(socket), title: decodeURIComponent(fromelem.videotitle), type: "playlist" });
{ mod: getSocketName(socket), title: tryDecodeURIComponent(fromelem.videotitle), type: "playlist" });
});
socket.on("forceVideoChange", function (data) {
if (!authService.can(socket.session, actions.ACTION_CONTROL_PLAYLIST)) {
Expand Down
2 changes: 1 addition & 1 deletion web/js/callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ socket.on('searchHistoryResults', function (data) {
entry.data('plobject', vid);
vid.domobj = entry;

$("<div/>").addClass('title').text(decodeURIComponent(vid.videotitle)).appendTo(entry);
$("<div/>").addClass('title').text(tryDecodeURIComponent(vid.videotitle)).appendTo(entry);

$("<div/>").addClass('delete').text("X").click(function () {
var video = $(this).parent().data('plobject');
Expand Down
9 changes: 9 additions & 0 deletions web/js/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,3 +337,12 @@ function onceFunction(fn) {
}
};
}

function tryDecodeURIComponent(str) {
try {
return decodeURIComponent(str);
} catch (err) {
console.warn('Ignored:', err);
return str;
}
}
2 changes: 1 addition & 1 deletion web/js/votecallbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ socket.on('searchHistoryResults', function (data) {
entry.data('plobject', vid);
vid.domobj = entry;

$("<div/>").addClass('title').text(decodeURIComponent(vid.videotitle)).appendTo(entry);
$("<div/>").addClass('title').text(tryDecodeURIComponent(vid.videotitle)).appendTo(entry);

$("<div/>").addClass('delete').text("X").click(function () {
var video = $(this).parent().data('plobject');
Expand Down
4 changes: 2 additions & 2 deletions web/plugins/toastthemes/toastthemes.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ function initToastThemes(data, textStatus, jqxhr) {

// Rig up the auto-theme method to the correct socket callback
socket.on('forceVideoChange', function(data) {
log('Video loaded: ' + decodeURIComponent(data.video.videotitle) + ' (id=' + data.video.videoid + ', duration=' + data.video.videolength + ')');
log('Video loaded: ' + tryDecodeURIComponent(data.video.videotitle) + ' (id=' + data.video.videoid + ', duration=' + data.video.videolength + ')');

// Sweetie Belle crawl
if (crawlId > -1) {
Expand Down Expand Up @@ -1128,7 +1128,7 @@ function gakify(node) {
var text;
if (gakified) {
text = node.data('plobject').videotitle;
return decodeURIComponent(text);
return tryDecodeURIComponent(text);
}
else {
text = node.find('.title').text();
Expand Down