lul
This commit is contained in:
parent
bfb9fa79de
commit
e62de626b4
BIN
bin/youtube-dl
Executable file
BIN
bin/youtube-dl
Executable file
Binary file not shown.
93
package-lock.json
generated
93
package-lock.json
generated
|
@ -81,14 +81,6 @@
|
|||
"resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
|
||||
"integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw="
|
||||
},
|
||||
"cloudscraper": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/cloudscraper/-/cloudscraper-1.5.0.tgz",
|
||||
"integrity": "sha512-bZagLhj59+N6Z6lD9zRksYu87GthLwXdKARULi4RZ6UVpotH39ruSFN3UQmw3uuqoj00iDxkGrapAvxeurmlQA==",
|
||||
"requires": {
|
||||
"request": "^2.49.0"
|
||||
}
|
||||
},
|
||||
"co": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
|
||||
|
@ -175,11 +167,6 @@
|
|||
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz",
|
||||
"integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I="
|
||||
},
|
||||
"file-type": {
|
||||
"version": "9.0.0",
|
||||
"resolved": "https://registry.npmjs.org/file-type/-/file-type-9.0.0.tgz",
|
||||
"integrity": "sha512-Qe/5NJrgIOlwijpq3B7BEpzPFcgzggOTagZmkXQY4LA6bsXKTUstK7Wp12lEJ/mLKTpvIZxmIuRcLYWT6ov9lw=="
|
||||
},
|
||||
"forever-agent": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
|
||||
|
@ -225,11 +212,6 @@
|
|||
"har-schema": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"html-entities": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/html-entities/-/html-entities-1.2.1.tgz",
|
||||
"integrity": "sha1-DfKTUfByEWNRXfueVUPl9u7VFi8="
|
||||
},
|
||||
"http-signature": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
|
||||
|
@ -314,14 +296,6 @@
|
|||
"yallist": "^2.1.2"
|
||||
}
|
||||
},
|
||||
"m3u8stream": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/m3u8stream/-/m3u8stream-0.3.0.tgz",
|
||||
"integrity": "sha512-0tvjXDIa6BolPEGo9zioQiPqfQhjopZXN3L7vZH/rZQCOLd4rPXNZc1UBMdW3TRpjNBoD0+F1X41/f0iY23rlQ==",
|
||||
"requires": {
|
||||
"miniget": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"mime-db": {
|
||||
"version": "1.36.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.36.0.tgz",
|
||||
|
@ -335,11 +309,6 @@
|
|||
"mime-db": "~1.36.0"
|
||||
}
|
||||
},
|
||||
"miniget": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/miniget/-/miniget-1.3.0.tgz",
|
||||
"integrity": "sha512-qvj5v1gbTvK6iVt1DqYrF0B9Lm6VAPNCa930TmTDQp6i1svDzzV8geu+e87XA14OBWDsWENptnP6BO9iJJOD9Q=="
|
||||
},
|
||||
"mysql2": {
|
||||
"version": "1.6.1",
|
||||
"resolved": "https://registry.npmjs.org/mysql2/-/mysql2-1.6.1.tgz",
|
||||
|
@ -372,6 +341,11 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node-fetch": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.2.0.tgz",
|
||||
"integrity": "sha512-OayFWziIxiHY8bCUyLX6sTpDH8Jsbp4FfYd1j1f7vZyfgkcOnAyM4oQR16f8a0s7Gl/viMGRey8eScYk4V4EZA=="
|
||||
},
|
||||
"nodejs-mysql2": {
|
||||
"version": "git+https://gitfap.de/Flummi/nodejs-mysql2.git#981d9f0946d25937675cb21a94099ad11a45d9fb",
|
||||
"from": "git+https://gitfap.de/Flummi/nodejs-mysql2.git",
|
||||
|
@ -390,26 +364,11 @@
|
|||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM="
|
||||
},
|
||||
"p-finally": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz",
|
||||
"integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4="
|
||||
},
|
||||
"p-try": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.0.0.tgz",
|
||||
"integrity": "sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ=="
|
||||
},
|
||||
"performance-now": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
|
||||
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns="
|
||||
},
|
||||
"pify": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pify/-/pify-4.0.0.tgz",
|
||||
"integrity": "sha512-zrSP/KDf9DH3K3VePONoCstgPiYJy9z0SCatZuTpOc7YdnWIqwkWdXOuwlr4uDc7em8QZRsFWsT/685x5InjYg=="
|
||||
},
|
||||
"pseudomap": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz",
|
||||
|
@ -430,15 +389,6 @@
|
|||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
|
||||
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
|
||||
},
|
||||
"read-chunk": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/read-chunk/-/read-chunk-3.0.0.tgz",
|
||||
"integrity": "sha512-8lBUVPjj9TC5bKLBacB+rpexM03+LWiYbv6ma3BeWmUYXGxqA1WNNgIZHq/iIsCrbFMzPhFbkOqdsyOFRnuoXg==",
|
||||
"requires": {
|
||||
"pify": "^4.0.0",
|
||||
"with-open-file": "^0.1.3"
|
||||
}
|
||||
},
|
||||
"redeyed": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/redeyed/-/redeyed-2.1.1.tgz",
|
||||
|
@ -502,11 +452,6 @@
|
|||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||
},
|
||||
"sax": {
|
||||
"version": "1.2.4",
|
||||
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
|
||||
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
|
||||
},
|
||||
"seq-queue": {
|
||||
"version": "0.0.5",
|
||||
"resolved": "https://registry.npmjs.org/seq-queue/-/seq-queue-0.0.5.tgz",
|
||||
|
@ -594,38 +539,10 @@
|
|||
"stack-trace": "0.0.x"
|
||||
}
|
||||
},
|
||||
"with-open-file": {
|
||||
"version": "0.1.3",
|
||||
"resolved": "https://registry.npmjs.org/with-open-file/-/with-open-file-0.1.3.tgz",
|
||||
"integrity": "sha512-sPUMcyWU0wde5lnHuDeEgAOIV4y77GpGmh9ktxb5HBfA2OwyWY7JtQYbBxuUFf/yv8Sbfrkxk+QbQwAyurvgXQ==",
|
||||
"requires": {
|
||||
"p-finally": "^1.0.0",
|
||||
"p-try": "^2.0.0",
|
||||
"pify": "^3.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"pify": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz",
|
||||
"integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY="
|
||||
}
|
||||
}
|
||||
},
|
||||
"yallist": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",
|
||||
"integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI="
|
||||
},
|
||||
"ytdl-core": {
|
||||
"version": "0.24.0",
|
||||
"resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-0.24.0.tgz",
|
||||
"integrity": "sha512-VwCe+uhKz2M1cH0UEnNxVQyLwGK8DIJgbUPF9svEh0zxUl2DP7LORCDIloLqDUxR6JnC3s01GU0YPxiOmjcqVA==",
|
||||
"requires": {
|
||||
"html-entities": "^1.1.3",
|
||||
"m3u8stream": "^0.3.0",
|
||||
"miniget": "^1.1.0",
|
||||
"sax": "^1.1.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,14 +9,10 @@
|
|||
"author": "Flummi",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"cloudscraper": "^1.5.0",
|
||||
"file-type": "^9.0.0",
|
||||
"node-fetch": "^2.2.0",
|
||||
"nodejs-mysql2": "git+https://gitfap.de/Flummi/nodejs-mysql2.git",
|
||||
"read-chunk": "^3.0.0",
|
||||
"request": "^2.88.0",
|
||||
"request-promise-native": "^1.0.5",
|
||||
"uuid": "^3.3.2",
|
||||
"winston": "^2.4.0",
|
||||
"ytdl-core": "^0.24.0"
|
||||
"winston": "^2.4.0"
|
||||
}
|
||||
}
|
||||
|
|
6
src/inc/trigger/inc/parser.mjs
Normal file
6
src/inc/trigger/inc/parser.mjs
Normal file
|
@ -0,0 +1,6 @@
|
|||
const formatSize = (size, i = ~~(Math.log(size) / Math.log(1024))) => (size / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i];
|
||||
|
||||
const getUUID = () => Math.random().toString(36).slice(-10) + (new Date()).getTime().toString(36).slice(-3);
|
||||
|
||||
|
||||
export { formatSize, getUUID };
|
|
@ -1,4 +1,4 @@
|
|||
import debug from "./debug";
|
||||
import parser from "./parser";
|
||||
import parser from "./parser_new";
|
||||
|
||||
export default [ debug, parser ];
|
||||
|
|
|
@ -24,7 +24,7 @@ const checkRepostCheckSum = (cs, cbcrcs) => {
|
|||
cbcrcs((rows[0].count == 0)?true:rows[0].id);
|
||||
});
|
||||
};
|
||||
const formatSize = (size) => {
|
||||
const formatSize = size => {
|
||||
const i = ~~(Math.log(size) / Math.log(1024));
|
||||
return (size / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i];
|
||||
};
|
||||
|
|
69
src/inc/trigger/parser_new.mjs
Normal file
69
src/inc/trigger/parser_new.mjs
Normal file
|
@ -0,0 +1,69 @@
|
|||
import { cfg } from "../cfg";
|
||||
import sql from "../sql";
|
||||
import * as lib from "./inc/parser";
|
||||
|
||||
import fs from "fs";
|
||||
import fetch from "node-fetch";
|
||||
import { promisify } from "util";
|
||||
import { execFile as ef } from "child_process";
|
||||
const execFile = promisify(ef);
|
||||
|
||||
const bin = process.cwd() + "/bin/youtube-dl";
|
||||
const b = process.cwd() + "/b";
|
||||
const _args = [ "--dump-json" ];
|
||||
|
||||
export default bot => {
|
||||
bot._trigger.set("parser", new bot.trigger({
|
||||
call: /https?:\/\/[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?/gi,
|
||||
f: e => {
|
||||
if(e.channel !== "#kbot-dev" && !e.message.match(/(!|-)f0ck/i))
|
||||
return;
|
||||
if(e.message.match(/(!|-)ignore/))
|
||||
return e.reply("ignored");
|
||||
|
||||
const tmp = e.message.match(/https?:\/\/[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?/gi); // get links
|
||||
tmp.forEach(link => execFile(bin, [...[link], ..._args])
|
||||
.then(({ stdout }) => JSON.parse(stdout))
|
||||
.then(data => data.direct ? {
|
||||
thumbnail: "",
|
||||
link: data.url,
|
||||
file: data.title,
|
||||
format: [{
|
||||
ext: data.ext,
|
||||
note: "direct",
|
||||
url: data.url,
|
||||
size: 0,
|
||||
rsize: 0
|
||||
}]
|
||||
} : {
|
||||
thumbnail: data.thumbnail,
|
||||
link: data.webpage_url,
|
||||
file: data.id,
|
||||
format: data.formats
|
||||
.filter(f => (f.filesize <= cfg.main.maxFileSize.val || f.ext === "mp3") && ["webm","mp4","mp3"].includes(f.ext))
|
||||
.splice(-1, 1)
|
||||
.map(f => ({
|
||||
ext: f.ext,
|
||||
note: f.format_note,
|
||||
url: f.url,
|
||||
size: lib.formatSize(f.filesize),
|
||||
rsize: f.filesize
|
||||
}))
|
||||
})
|
||||
.then(data => {
|
||||
if(data.format.length === 0)
|
||||
return e.reply("no filters found, f0ck! D:");
|
||||
fetch(data.format[0].url, { size: cfg.main.maxFileSize.val })
|
||||
.then(res => {
|
||||
const uuid = lib.getUUID();
|
||||
const dest = fs.createWriteStream(b + "/" + uuid + "." + data.format[0].ext);
|
||||
res.body.pipe(dest);
|
||||
e.reply(`gef0ckt lol: ${data.file} -> ${uuid}.${data.format[0].ext}, ~${data.format[0].size}`);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
}));
|
||||
}
|
||||
}));
|
||||
};
|
Loading…
Reference in New Issue
Block a user