Add proper support for gfycat gifs, attempt to handle image errors "better", added some new activity messages
This commit is contained in:
parent
116ed94ca3
commit
b2b8fd643a
3 changed files with 24 additions and 8 deletions
|
@ -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?"
|
||||
]
|
|
@ -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});
|
||||
const data = await promisify(magick[object.cmd])(objectWithFixedType);
|
||||
const returnObject = {
|
||||
buffer: data,
|
||||
fileExtension
|
||||
};
|
||||
resolve(returnObject);
|
||||
try {
|
||||
const data = await promisify(magick[object.cmd])(objectWithFixedType);
|
||||
const returnObject = {
|
||||
buffer: data,
|
||||
fileExtension
|
||||
};
|
||||
resolve(returnObject);
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue