Add proper support for gfycat gifs, attempt to handle image errors "better", added some new activity messages

This commit is contained in:
TheEssem 2021-01-17 20:40:52 -06:00
parent 116ed94ca3
commit b2b8fd643a
3 changed files with 24 additions and 8 deletions

View file

@ -117,5 +117,9 @@
"btw I use arch",
"Friday Night Funkin'",
"fgsfds",
"Doilus Stage"
"Doilus Stage",
"please report any issues you find thank you",
"xfce real",
"OpenRCT2",
"Sus? As in the popular video game Among Us?"
]

View file

@ -4,7 +4,7 @@ const execPromise = promisify(require("child_process").exec);
const { isMainThread, parentPort, workerData } = require("worker_threads");
exports.run = async object => {
return new Promise(async resolve => {
return new Promise(async (resolve, reject) => {
// If the image has a path, it must also have a type
if (object.path) {
if (object.type !== "image/gif" && object.onlyGIF) resolve({
@ -19,12 +19,16 @@ exports.run = async object => {
// If no image type is given (say, the command generates its own image), make it a PNG.
const fileExtension = object.type ? object.type.split("/")[1] : "png";
const objectWithFixedType = Object.assign({}, object, {type: fileExtension});
try {
const data = await promisify(magick[object.cmd])(objectWithFixedType);
const returnObject = {
buffer: data,
fileExtension
};
resolve(returnObject);
} catch (e) {
reject(e);
}
});
};

View file

@ -17,6 +17,12 @@ const imgurURLs = [
"www.imgur.com",
"i.imgur.com"
];
const gfycatURLs = [
"gfycat.com",
"www.gfycat.com",
"thumbs.gfycat.com",
"giant.gfycat.com"
];
const formats = ["image/jpeg", "image/png", "image/webp", "image/gif"];
@ -42,6 +48,8 @@ const getImage = async (image, image2, gifv = false) => {
payload.path = `https://media0.giphy.com/media/${image2.split("-").pop()}/giphy.gif`;
} else if (imgurURLs.includes(host)) {
payload.path = image.replace(".mp4", ".gif");
} else if (gfycatURLs.includes(host)) {
payload.path = `https://thumbs.gfycat.com/${image.split("/").pop().split(".mp4")[0]}-size_restricted.gif`;
}
payload.type = "image/gif";
} else {