diff --git a/src/inc/routes/index.mjs b/src/inc/routes/index.mjs index 9d936dc..ad57a01 100644 --- a/src/inc/routes/index.mjs +++ b/src/inc/routes/index.mjs @@ -10,7 +10,7 @@ const auth = async (req, res, next) => { }; export default (router, tpl) => { - router.get(/\/user\/(?.*)/, async (req, res) => { + router.get(/\/user\/(?.*)/, lib.loggedin, async (req, res) => { const user = decodeURIComponent(req.params.user); const query = await db` @@ -82,6 +82,9 @@ export default (router, tpl) => { router.get(/^\/?(?:\/tag\/(?.+?))?(?:\/user\/(?.+?)\/(?f0cks|favs))?(?:\/(?image|audio|video))?(?:\/p\/(?\d+))?(?:\/(?\d+))?$/, async (req, res) => { 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)({ user: req.params.user, tag: req.params.tag, diff --git a/src/inc/routes/random.mjs b/src/inc/routes/random.mjs index 6af00c1..a8b5fe2 100644 --- a/src/inc/routes/random.mjs +++ b/src/inc/routes/random.mjs @@ -1,8 +1,9 @@ import cfg from "../../inc/config.mjs"; +import lib from "../lib.mjs"; import f0cklib from "../routeinc/f0cklib.mjs"; export default (router, tpl) => { - router.get(/^\/random$/, async (req, res) => { + router.get(/^\/random$/, lib.loggedin, async (req, res) => { let referer = req.headers.referer ?? ''; let opts = {}; diff --git a/src/inc/trigger/parser.mjs b/src/inc/trigger/parser.mjs index e81be20..17a5336 100644 --- a/src/inc/trigger/parser.mjs +++ b/src/inc/trigger/parser.mjs @@ -73,7 +73,7 @@ export default async bot => { // is instagram try { // @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; } catch(err) { const tmphead = (await fetch(link, { method: "HEAD" })).headers["content-type"]; @@ -88,7 +88,7 @@ export default async bot => { else { // is not instagram 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; } catch(err) { const tmphead = (await fetch(link, { method: "HEAD" })).headers["content-type"]; @@ -112,7 +112,7 @@ export default async bot => { if(link.match(regex.instagram)) { try { // add --cookies 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) { if(e.type == 'tg') 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)) { // imghure via torsocks 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}`; } catch(err) { console.error('err:', err); @@ -133,7 +134,7 @@ export default async bot => { } else { 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) { console.error('err:', err); if(e.type == 'tg')