current live version
Some checks failed
fetch npm modules / f0ck the f0cker (push) Failing after 1s

This commit is contained in:
Flummi 2024-12-28 12:43:34 +01:00
parent 70df109d1b
commit 65be5dc3e8
3 changed files with 12 additions and 7 deletions

View File

@ -10,7 +10,7 @@ const auth = async (req, res, next) => {
}; };
export default (router, tpl) => { export default (router, tpl) => {
router.get(/\/user\/(?<user>.*)/, async (req, res) => { router.get(/\/user\/(?<user>.*)/, lib.loggedin, async (req, res) => {
const user = decodeURIComponent(req.params.user); const user = decodeURIComponent(req.params.user);
const query = await db` const query = await db`
@ -82,6 +82,9 @@ export default (router, tpl) => {
router.get(/^\/?(?:\/tag\/(?<tag>.+?))?(?:\/user\/(?<user>.+?)\/(?<mode>f0cks|favs))?(?:\/(?<mime>image|audio|video))?(?:\/p\/(?<page>\d+))?(?:\/(?<itemid>\d+))?$/, async (req, res) => { router.get(/^\/?(?:\/tag\/(?<tag>.+?))?(?:\/user\/(?<user>.+?)\/(?<mode>f0cks|favs))?(?:\/(?<mime>image|audio|video))?(?:\/p\/(?<page>\d+))?(?:\/(?<itemid>\d+))?$/, async (req, res) => {
const mode = req.params.itemid ? 'item' : 'index'; const mode = req.params.itemid ? 'item' : 'index';
if(mode === 'item' && !req.session)
return res.redirect('/login');
const data = await (req.params.itemid ? f0cklib.getf0ck : f0cklib.getf0cks)({ const data = await (req.params.itemid ? f0cklib.getf0ck : f0cklib.getf0cks)({
user: req.params.user, user: req.params.user,
tag: req.params.tag, tag: req.params.tag,

View File

@ -1,8 +1,9 @@
import cfg from "../../inc/config.mjs"; import cfg from "../../inc/config.mjs";
import lib from "../lib.mjs";
import f0cklib from "../routeinc/f0cklib.mjs"; import f0cklib from "../routeinc/f0cklib.mjs";
export default (router, tpl) => { export default (router, tpl) => {
router.get(/^\/random$/, async (req, res) => { router.get(/^\/random$/, lib.loggedin, async (req, res) => {
let referer = req.headers.referer ?? ''; let referer = req.headers.referer ?? '';
let opts = {}; let opts = {};

View File

@ -73,7 +73,7 @@ export default async bot => {
// 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 ${cfg.main.socks} -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 --proxy ${cfg.main.socks} -f 'bv*[height<=720]+ba/b[height<=720] / wv*+ba/w' --skip-download --dump-json "${link}"`)).stdout);
ext = meta.ext; ext = meta.ext;
} catch(err) { } catch(err) {
const tmphead = (await fetch(link, { method: "HEAD" })).headers["content-type"]; const tmphead = (await fetch(link, { method: "HEAD" })).headers["content-type"];
@ -88,7 +88,7 @@ export default async bot => {
else { else {
// is not instagram // is not instagram
try { try {
const meta = JSON.parse((await queue.exec(`yt-dlp ${cfg.main.socks} -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 --proxy ${cfg.main.socks} -f 'bv*[height<=720]+ba/b[height<=720] / wv*+ba/w' --skip-download --dump-json "${link}"`)).stdout);
ext = meta.ext; ext = meta.ext;
} catch(err) { } catch(err) {
const tmphead = (await fetch(link, { method: "HEAD" })).headers["content-type"]; const tmphead = (await fetch(link, { method: "HEAD" })).headers["content-type"];
@ -112,7 +112,7 @@ export default async bot => {
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
source = (await queue.exec(`yt-dlp ${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 --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) { } catch(err) {
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");
@ -122,7 +122,8 @@ export default async bot => {
else if(link.match(regex.imgur)) { else if(link.match(regex.imgur)) {
// imghure via torsocks // imghure via torsocks
try { try {
await queue.exec(`torsocks wget ${link} -O ./tmp/${uuid}.${ext}`); //await queue.exec(`torsocks wget ${link} -O ./tmp/${uuid}.${ext}`);
await queue.exec(`curl -x ${cfg.main.socks} ${link} --output ./tmp/${uuid}.${ext}`);
source = `./tmp/${uuid}.${ext}`; source = `./tmp/${uuid}.${ext}`;
} catch(err) { } catch(err) {
console.error('err:', err); console.error('err:', err);
@ -133,7 +134,7 @@ export default async bot => {
} }
else { else {
try { try {
source = (await queue.exec(`yt-dlp ${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 --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) { } catch(err) {
console.error('err:', err); console.error('err:', err);
if(e.type == 'tg') if(e.type == 'tg')