fingers crossed this shit works first try
All checks were successful
fetch npm modules / f0ck the f0cker (push) Successful in 47s
All checks were successful
fetch npm modules / f0ck the f0cker (push) Successful in 47s
This commit is contained in:
@@ -12,6 +12,7 @@ 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\/(\S*)(\..{3,4})/i,
|
||||
fourchan: /https?:\/\/i\.4cdn\.org\/(\w+)\/(\d+)\.(\w{3,4})/i,
|
||||
instagram: /(?:https?:\/\/www\.)?instagram\.com\S*?\/(?:p|reel)\/(\w{11})\/?/im
|
||||
};
|
||||
const mediagroupids = new Set();
|
||||
@@ -88,8 +89,8 @@ export default async bot => {
|
||||
// imghure
|
||||
ext = link.split('.').pop();
|
||||
}
|
||||
else {
|
||||
// is not instagram
|
||||
else if(link.match(regex.fourchan)) {
|
||||
//4chan - fuck cloudflare :)
|
||||
try {
|
||||
const meta = JSON.parse((await queue.exec(`yt-dlp --proxy ${cfg.main.socks} -f 'bv*[height<=720]+ba/b[height<=720] / wv*+ba/w' --skip-download --dump-json "${link}"`)).stdout);
|
||||
ext = meta.ext;
|
||||
@@ -99,6 +100,18 @@ export default async bot => {
|
||||
ext = cfg.mimes[tmphead];
|
||||
}
|
||||
}
|
||||
else {
|
||||
// is not instagram aka everything else that is not a exception
|
||||
// not using proxy
|
||||
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;
|
||||
} catch(err) {
|
||||
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
|
||||
ext = cfg.mimes[tmphead];
|
||||
}
|
||||
}
|
||||
|
||||
if(!Object.values(cfg.mimes).includes(ext?.toLowerCase())) {
|
||||
return console.log('mime schmime ' + ext);
|
||||
@@ -114,7 +127,7 @@ export default async bot => {
|
||||
|
||||
if(link.match(regex.instagram)) {
|
||||
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 or optionally use a socks proxy from a network that is not being detected as a public network
|
||||
source = (await queue.exec(`yt-dlp --proxy ${cfg.main.socks} -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')
|
||||
@@ -123,7 +136,7 @@ export default async bot => {
|
||||
}
|
||||
}
|
||||
else if(link.match(regex.imgur)) {
|
||||
// imghure via torsocks
|
||||
// imghure via torsocks // needs torsocks setup so this is optional
|
||||
try {
|
||||
await queue.exec(`torsocks wget ${link} -O ./tmp/${uuid}.${ext}`);
|
||||
source = `./tmp/${uuid}.${ext}`;
|
||||
@@ -136,7 +149,17 @@ export default async bot => {
|
||||
}
|
||||
else if(link.match(regex.yt)) {
|
||||
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 or optionally use a socks proxy from a network that is not being detected as a public network
|
||||
source = (await queue.exec(`yt-dlp --proxy ${cfg.main.socks} -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, "yt dl error");
|
||||
return await e.reply("yt dl error", err);
|
||||
}
|
||||
}
|
||||
else if(link.match(regex.fourchan)) {
|
||||
// 4chan via proxy - fuck cloudflare
|
||||
try {
|
||||
source = (await queue.exec(`yt-dlp --proxy ${cfg.main.socks} -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')
|
||||
@@ -145,8 +168,9 @@ export default async bot => {
|
||||
}
|
||||
}
|
||||
else {
|
||||
// everything except the exceptions
|
||||
try {
|
||||
source = (await queue.exec(`yt-dlp --proxy ${cfg.main.socks} -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();
|
||||
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) {
|
||||
console.error('err:', err);
|
||||
if(e.type == 'tg')
|
||||
|
Reference in New Issue
Block a user