blah
This commit is contained in:
parent
30ac7ef6be
commit
728f044066
133
package-lock.json
generated
133
package-lock.json
generated
@ -12,6 +12,7 @@
|
||||
"cuffeo": "^1.2.2",
|
||||
"flumm-fetch": "^1.0.1",
|
||||
"flummpress": "^2.0.5",
|
||||
"node-fetch": "^3.3.2",
|
||||
"postgres": "^3.3.4"
|
||||
}
|
||||
},
|
||||
@ -23,6 +24,38 @@
|
||||
"flumm-fetch": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/data-uri-to-buffer": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
|
||||
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 12"
|
||||
}
|
||||
},
|
||||
"node_modules/fetch-blob": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
|
||||
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/jimmywarting"
|
||||
},
|
||||
{
|
||||
"type": "paypal",
|
||||
"url": "https://paypal.me/jimmywarting"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"node-domexception": "^1.0.0",
|
||||
"web-streams-polyfill": "^3.0.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.20 || >= 14.13"
|
||||
}
|
||||
},
|
||||
"node_modules/flumm-fetch": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/flumm-fetch/-/flumm-fetch-1.0.1.tgz",
|
||||
@ -33,6 +66,55 @@
|
||||
"resolved": "https://registry.npmjs.org/flummpress/-/flummpress-2.0.5.tgz",
|
||||
"integrity": "sha512-C/8Im6OvoZw67q9DvYIXKjKr28zHYLJdH4DucQ6zpVbN1eWPySmxkJTURbkq3uEwABXLngXLifS6mjxAC++umQ=="
|
||||
},
|
||||
"node_modules/formdata-polyfill": {
|
||||
"version": "4.0.10",
|
||||
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
|
||||
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"fetch-blob": "^3.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.20.0"
|
||||
}
|
||||
},
|
||||
"node_modules/node-domexception": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
|
||||
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/jimmywarting"
|
||||
},
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://paypal.me/jimmywarting"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "3.3.2",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz",
|
||||
"integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"data-uri-to-buffer": "^4.0.0",
|
||||
"fetch-blob": "^3.1.4",
|
||||
"formdata-polyfill": "^4.0.10"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/node-fetch"
|
||||
}
|
||||
},
|
||||
"node_modules/postgres": {
|
||||
"version": "3.3.4",
|
||||
"resolved": "https://registry.npmjs.org/postgres/-/postgres-3.3.4.tgz",
|
||||
@ -41,6 +123,15 @@
|
||||
"type": "individual",
|
||||
"url": "https://github.com/sponsors/porsager"
|
||||
}
|
||||
},
|
||||
"node_modules/web-streams-polyfill": {
|
||||
"version": "3.3.3",
|
||||
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz",
|
||||
"integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 8"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
@ -52,6 +143,20 @@
|
||||
"flumm-fetch": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"data-uri-to-buffer": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
|
||||
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A=="
|
||||
},
|
||||
"fetch-blob": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
|
||||
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
|
||||
"requires": {
|
||||
"node-domexception": "^1.0.0",
|
||||
"web-streams-polyfill": "^3.0.3"
|
||||
}
|
||||
},
|
||||
"flumm-fetch": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/flumm-fetch/-/flumm-fetch-1.0.1.tgz",
|
||||
@ -62,10 +167,38 @@
|
||||
"resolved": "https://registry.npmjs.org/flummpress/-/flummpress-2.0.5.tgz",
|
||||
"integrity": "sha512-C/8Im6OvoZw67q9DvYIXKjKr28zHYLJdH4DucQ6zpVbN1eWPySmxkJTURbkq3uEwABXLngXLifS6mjxAC++umQ=="
|
||||
},
|
||||
"formdata-polyfill": {
|
||||
"version": "4.0.10",
|
||||
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
|
||||
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
|
||||
"requires": {
|
||||
"fetch-blob": "^3.1.2"
|
||||
}
|
||||
},
|
||||
"node-domexception": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
|
||||
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ=="
|
||||
},
|
||||
"node-fetch": {
|
||||
"version": "3.3.2",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz",
|
||||
"integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==",
|
||||
"requires": {
|
||||
"data-uri-to-buffer": "^4.0.0",
|
||||
"fetch-blob": "^3.1.4",
|
||||
"formdata-polyfill": "^4.0.10"
|
||||
}
|
||||
},
|
||||
"postgres": {
|
||||
"version": "3.3.4",
|
||||
"resolved": "https://registry.npmjs.org/postgres/-/postgres-3.3.4.tgz",
|
||||
"integrity": "sha512-XVu0+d/Y56pl2lSaf0c7V19AhAEfpVrhID1IENWN8nf0xch6hFq6dAov5dtUX6ZD46wfr1TxvLhxLtV8WnNsOg=="
|
||||
},
|
||||
"web-streams-polyfill": {
|
||||
"version": "3.3.3",
|
||||
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz",
|
||||
"integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw=="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
"cuffeo": "^1.2.2",
|
||||
"flumm-fetch": "^1.0.1",
|
||||
"flummpress": "^2.0.5",
|
||||
"node-fetch": "^3.3.2",
|
||||
"postgres": "^3.3.4"
|
||||
}
|
||||
}
|
||||
|
@ -149,8 +149,16 @@ class v0ck {
|
||||
|
||||
player.addEventListener('click', e => {
|
||||
const path = e.path || (e.composedPath && e.composedPath());
|
||||
if(!path.filter(f => f.classList?.contains('v0ck_player_controls')).length)
|
||||
togglePlay(e);
|
||||
if(path.filter(f => f.classList?.contains('v0ck_player_controls')).length)
|
||||
return;
|
||||
|
||||
//navigator.userAgentData = { mobile: true };
|
||||
if(navigator.userAgentData?.mobile) { // mobile
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
togglePlay(e);
|
||||
});
|
||||
toggle.addEventListener('click', togglePlay);
|
||||
video.addEventListener('play', updatePlayIcon);
|
||||
|
@ -1,6 +1,13 @@
|
||||
import fetch from 'flumm-fetch';
|
||||
import fetch from 'node-fetch';
|
||||
import cfg from './config.mjs';
|
||||
|
||||
const parseOutput = text => {
|
||||
text = text.trim().toLowerCase();
|
||||
return text.includes(', ')
|
||||
? text.split(', ')
|
||||
: text.replace(/\d\. /g, '').split('\n');
|
||||
};
|
||||
|
||||
export default new class autotagger {
|
||||
async isNSFW(filename, filesize) {
|
||||
let opts = {
|
||||
@ -29,4 +36,34 @@ export default new class autotagger {
|
||||
else
|
||||
return res.unsafe;
|
||||
};
|
||||
|
||||
async getTags(id) {
|
||||
if(!id)
|
||||
return;
|
||||
|
||||
try {
|
||||
const f0ck = `${cfg.main.url.full}/t/${id}.webp`;
|
||||
const blob = await (await fetch(f0ck)).arrayBuffer();
|
||||
|
||||
const res = await fetch(`${cfg.apis.cf.url}/${cfg.apis.cf.id}/ai/run/${cfg.apis.cf.model}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": `Bearer ${cfg.apis.cf.key}`
|
||||
},
|
||||
body: JSON.stringify({
|
||||
image: [ ...new Uint8Array(blob) ],
|
||||
prompt: "Generate eight comma separated tags without colors for this image.",
|
||||
max_tokens: 128
|
||||
})
|
||||
});
|
||||
const json = await res.json();
|
||||
console.log(json.result.description);
|
||||
return parseOutput(json.result.description);
|
||||
} catch(err) {
|
||||
return {
|
||||
error: err.message || "unknown error"
|
||||
};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -98,6 +98,7 @@ export default async bot => {
|
||||
}
|
||||
|
||||
if(!Object.values(cfg.mimes).includes(ext?.toLowerCase())) {
|
||||
await e.reply("mime schmime");
|
||||
return console.log('mime schmime ' + ext);
|
||||
}
|
||||
|
||||
@ -254,29 +255,12 @@ export default async bot => {
|
||||
let speed = lib.calcSpeed(size, end);
|
||||
speed = !Number.isFinite(speed) ? "yes" : `${speed.toFixed(2)} Mbit/s`;
|
||||
|
||||
// autotagger
|
||||
let tags = [];
|
||||
/*if(cfg.apis?.nsfw1 && mime.startsWith('image')) {
|
||||
const nsfw = await autotagger.isNSFW(filename, size);
|
||||
tags.push(nsfw ? 'nsfw' : 'sfw');
|
||||
if(nsfw)
|
||||
await queue.tagNSFW(itemid);
|
||||
else
|
||||
await queue.tagSFW(itemid);
|
||||
}*/
|
||||
|
||||
let outputmsgirc = `[f0cked] link: ${cfg.main.url.full}/${itemid} | size: ${lib.formatSize(size)} | speed: ${speed}`;
|
||||
let outputmsgtg = `[f0cked] size: ${lib.formatSize(size)} | speed: ${speed}`;
|
||||
|
||||
if(tags?.length > 0) {
|
||||
const tagstr = tags.join(', ');
|
||||
outputmsgirc += ` | tags: ${tagstr}`;
|
||||
outputmsgtg += ` | tags: ${tagstr}`;
|
||||
}
|
||||
|
||||
if(e.type == 'tg') {
|
||||
await e.deleteMessage(msg.result.chat.id, msg.result.message_id);
|
||||
await e.reply(outputmsgtg, {
|
||||
/*await e.reply(outputmsgtg, {
|
||||
reply_markup: JSON.stringify({
|
||||
inline_keyboard: [[
|
||||
{ text: (await lib.hasTag(itemid, 1) ? '✓ ' : '') + 'sfw', callback_data: `b_sfw:${itemid}` },
|
||||
@ -287,6 +271,42 @@ export default async bot => {
|
||||
{ text: `open f0ck #${itemid}`, url: `${cfg.main.url.full}/${itemid}` }
|
||||
]]
|
||||
})
|
||||
});*/
|
||||
|
||||
let tags;
|
||||
|
||||
try {
|
||||
tags = (await autotagger.getTags(itemid))
|
||||
.map(t => ({ text: t, callback_data: 'nope' }));
|
||||
await e.reply(outputmsgtg, {
|
||||
reply_markup: JSON.stringify({
|
||||
inline_keyboard: [[
|
||||
{ text: (await lib.hasTag(itemid, 1) ? '✓ ' : '') + 'sfw', callback_data: `b_sfw:${itemid}` },
|
||||
{ text: (await lib.hasTag(itemid, 2) ? '✓ ' : '') + 'nsfw', callback_data: `b_nsfw:${itemid}` },
|
||||
],
|
||||
[ ...tags.splice(0, 4) ],
|
||||
[ ...tags.splice(0, 4) ],
|
||||
[
|
||||
{ text: `open f0ck #${itemid}`, url: `${cfg.main.url.full}/${itemid}` },
|
||||
{ text: '❌ delete', callback_data: `b_delete:${itemid}` }
|
||||
]]
|
||||
})
|
||||
});
|
||||
return;
|
||||
} catch(err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
await e.reply(outputmsgtg, {
|
||||
reply_markup: JSON.stringify({
|
||||
inline_keyboard: [[
|
||||
{ text: (await lib.hasTag(itemid, 1) ? '✓ ' : '') + 'sfw', callback_data: `b_sfw:${itemid}` },
|
||||
{ text: (await lib.hasTag(itemid, 2) ? '✓ ' : '') + 'nsfw', callback_data: `b_nsfw:${itemid}` },
|
||||
], [
|
||||
{ text: `open f0ck #${itemid}`, url: `${cfg.main.url.full}/${itemid}` },
|
||||
{ text: '❌ delete', callback_data: `b_delete:${itemid}` }
|
||||
]]
|
||||
})
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user