From 84c58479eb817f771c8c0248fca52f15a1b25348 Mon Sep 17 00:00:00 2001 From: Abu Ottermann Date: Sun, 18 Feb 2024 21:33:53 +0100 Subject: [PATCH] pure verzweiflung mit js --- src/inc/trigger/parser.mjs | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/inc/trigger/parser.mjs b/src/inc/trigger/parser.mjs index 4b923da..d66b2c6 100644 --- a/src/inc/trigger/parser.mjs +++ b/src/inc/trigger/parser.mjs @@ -11,7 +11,8 @@ import path from "path"; const regex = { all: /https?:\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?/gi, yt: /(?:youtube\.com\/\S*(?:(?:\/e(?:mbed))?\/|watch\/?\?(?:\S*?&?v\=))|youtu\.be\/)([a-zA-Z0-9_-]{6,11})/gi, - imgur: /^https?:\/\/(\w+\.)?imgur.com\/(\w*\d\w*)+(\.[a-zA-Z]{3,4})?/gi + imgur: /^https?:\/\/(\w+\.)?imgur.com\/(\w*\d\w*)+(\.[a-zA-Z]{3,4})?/gi, + instagram: /^https?:\/\/(\w+\.)?instagram.com\/p\/(.*)\//gi }; const mediagroupids = new Set(); @@ -51,7 +52,7 @@ export default async bot => { links.forEach(async link => { if(regex.imgur.test(link)) - return await e.reply(`imgur is not supported!`); + await e.reply(`imgur detected?`); // check repost (link) repost = await queue.checkrepostlink(link); @@ -65,6 +66,9 @@ export default async bot => { // read metadata let ext; + if(regex.imgur.test(link)) + ext = link.split('.').pop(); + // blah? try { const meta = JSON.parse((await queue.exec(`yt-dlp -f 'bv*[height<=720]+ba/b[height<=720] / wv*+ba/w' --skip-download --dump-json "${link}"`)).stdout); ext = meta.ext; @@ -85,20 +89,30 @@ export default async bot => { // download data const start = new Date(); let source; - try { - source = (await queue.exec(`yt-dlp -f 'bv*[height<=720]+ba/b[height<=720] / wv*+ba/w' "${link}" --max-filesize ${maxfilesize / 1024}k --postprocessor-args "ffmpeg:-bitexact" -o "./tmp/${uuid}.%(ext)s" --print after_move:filepath --merge-output-format "mp4"`)).stdout.trim(); - } catch(err) { - if(e.type == 'tg') - return await e.editMessageText(msg.result.chat.id, msg.result.message_id, "something went wrong lol"); - return await e.reply("something went wrong lol"); + if(regex.imgur.test(link)) + try { + source = (await queue.exec(`wget "${link}" -o "/home/f0ck/f0ckv2/tmp/${uuid}.${ext}"`)).stdout.trim(); + } catch(err) { + return await e.reply("fuck js"); + } + else { + try { + source = (await queue.exec(`yt-dlp -f 'bv*[height<=720]+ba/b[height<=720] / wv*+ba/w' "${link}" --max-filesize ${maxfilesize / 1024}k --postprocessor-args "ffmpeg:-bitexact" -o "./tmp/${uuid}.%(ext)s" --print after_move:filepath --merge-output-format "mp4"`)).stdout.trim(); + } catch(err) { + if(e.type == 'tg') + return await e.editMessageText(msg.result.chat.id, msg.result.message_id, "something went wrong lol"); + return await e.reply("something went wrong lol 1"); + } } if(!source) { if(e.type == 'tg') return await e.editMessageText(msg.result.chat.id, msg.result.message_id, "something went wrong lol"); - return await e.reply("something went wrong lol"); + return await e.reply("something went wrong lol 2"); } + console.log(typeof source) + if(source.match(/larger than/)) { if(e.type == 'tg') return await e.editMessageText(msg.result.chat.id, msg.result.message_id, "too large lol");