This commit is contained in:
parent
95902023e9
commit
d0336d8cfb
|
@ -11,11 +11,7 @@ import path from "path";
|
||||||
const regex = {
|
const regex = {
|
||||||
all: /https?:\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?/gi,
|
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,
|
yt: /(?:youtube\.com\/\S*(?:(?:\/e(?:mbed))?\/|watch\/?\?(?:\S*?&?v\=))|youtu\.be\/)([a-zA-Z0-9_-]{6,11})/gi,
|
||||||
<<<<<<< HEAD
|
|
||||||
imgur: /(?:https?:)?\/\/(\w+\.)?imgur\.com\/(\S*)(\.[a-zA-Z]{3})/gm,
|
|
||||||
=======
|
|
||||||
imgur: /(?:https?:)?\/\/(\w+\.)?imgur\.com\/(\S*)(\.[a-zA-Z]{3,4})/gi,
|
imgur: /(?:https?:)?\/\/(\w+\.)?imgur\.com\/(\S*)(\.[a-zA-Z]{3,4})/gi,
|
||||||
>>>>>>> 2b2fe45 (imgur schmimgur)
|
|
||||||
instagram: /(?:https?:\/\/www\.)?instagram\.com\S*?\/(?:p|reel)\/(\w{11})\/?/im
|
instagram: /(?:https?:\/\/www\.)?instagram\.com\S*?\/(?:p|reel)\/(\w{11})\/?/im
|
||||||
};
|
};
|
||||||
const mediagroupids = new Set();
|
const mediagroupids = new Set();
|
||||||
|
@ -55,13 +51,8 @@ export default async bot => {
|
||||||
console.log(`parsing ${links.length} link${links.length > 1 ? "s" : ""}...`);
|
console.log(`parsing ${links.length} link${links.length > 1 ? "s" : ""}...`);
|
||||||
|
|
||||||
links.forEach(async link => {
|
links.forEach(async link => {
|
||||||
<<<<<<< HEAD
|
|
||||||
if(regex.imgur.test(link))
|
|
||||||
await e.reply(`imgur schmimigur`);
|
|
||||||
=======
|
|
||||||
//if(regex.imgur.test(link))
|
//if(regex.imgur.test(link))
|
||||||
// return await e.reply(`fuck imgur... seriously`);
|
// return await e.reply(`fuck imgur... seriously`);
|
||||||
>>>>>>> 2b2fe45 (imgur schmimgur)
|
|
||||||
|
|
||||||
if(regex.instagram.test(link))
|
if(regex.instagram.test(link))
|
||||||
await e.reply(`insta schminsta`);
|
await e.reply(`insta schminsta`);
|
||||||
|
@ -78,34 +69,22 @@ export default async bot => {
|
||||||
|
|
||||||
// read metadata
|
// read metadata
|
||||||
let ext;
|
let ext;
|
||||||
<<<<<<< HEAD
|
|
||||||
if(regex.imgur.test(link)) {
|
|
||||||
// is imgur
|
|
||||||
try {
|
|
||||||
// will die extension von der url
|
|
||||||
ext = link.split(".").slice(-1).join(".");
|
|
||||||
=======
|
|
||||||
if(link.match(regex.instagram)) {
|
if(link.match(regex.instagram)) {
|
||||||
// is instagram
|
// is instagram
|
||||||
try {
|
try {
|
||||||
// @flummi -> is there a variable for the actual work directory so it doesn't have to be hardcoded?
|
// @flummi -> is there a variable for the actual work directory so it doesn't have to be hardcoded?
|
||||||
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);
|
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;
|
ext = meta.ext;
|
||||||
>>>>>>> 2b2fe45 (imgur schmimgur)
|
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
const tmphead = (await fetch(link, { method: "HEAD" })).headers["content-type"];
|
const tmphead = (await fetch(link, { method: "HEAD" })).headers["content-type"];
|
||||||
// this can be undefined for unsupported mime types, but will be caught in the general mime check below
|
// this can be undefined for unsupported mime types, but will be caught in the general mime check below
|
||||||
ext = cfg.mimes[tmphead];
|
ext = cfg.mimes[tmphead];
|
||||||
<<<<<<< HEAD
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(link.match(regex.imgur)) {
|
else if(link.match(regex.imgur)) {
|
||||||
// imghure
|
// imghure
|
||||||
ext = link.split('.').pop();
|
ext = link.split('.').pop();
|
||||||
await e.reply(`extension: ${ext}`);
|
await e.reply(`extension: ${ext}`);
|
||||||
>>>>>>> 2b2fe45 (imgur schmimgur)
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// is not instagram
|
// is not instagram
|
||||||
|
@ -131,37 +110,6 @@ export default async bot => {
|
||||||
const start = new Date();
|
const start = new Date();
|
||||||
let source;
|
let source;
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
try {
|
|
||||||
if(regex.instagram.test(link))
|
|
||||||
try {
|
|
||||||
// add --cookies <path-to-cookies-file> on local instance if you want to avoid getting rate limited
|
|
||||||
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, "instagram dl error");
|
|
||||||
return await e.reply("instagram dl error", err);
|
|
||||||
}
|
|
||||||
else if(regex.imgur.test(link)) {
|
|
||||||
console.log("penis123");
|
|
||||||
try {
|
|
||||||
await queue.exec(`torsocks wget "${link}" -O "./tmp/${uuid}.${ext}"`);
|
|
||||||
source = "./tmp/"+uuid+"."+ext;
|
|
||||||
console.log(source);
|
|
||||||
} catch(err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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, err);
|
|
||||||
return await e.reply(err);
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
if(link.match(regex.instagram)) {
|
if(link.match(regex.instagram)) {
|
||||||
try {
|
try {
|
||||||
// add --cookies <path-to-cookies-file> on local instance if you want to avoid getting rate limited
|
// add --cookies <path-to-cookies-file> on local instance if you want to avoid getting rate limited
|
||||||
|
@ -170,7 +118,6 @@ export default async bot => {
|
||||||
if(e.type == 'tg')
|
if(e.type == 'tg')
|
||||||
return await e.editMessageText(msg.result.chat.id, msg.result.message_id, "instagram dl error");
|
return await e.editMessageText(msg.result.chat.id, msg.result.message_id, "instagram dl error");
|
||||||
return await e.reply("instagram dl error", err);
|
return await e.reply("instagram dl error", err);
|
||||||
>>>>>>> 2b2fe45 (imgur schmimgur)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(link.match(regex.imgur)) {
|
else if(link.match(regex.imgur)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user