This commit is contained in:
Flummi
2020-10-13 10:59:06 +02:00
parent 22527d2552
commit a01f19c644
4 changed files with 18 additions and 15 deletions

View File

@@ -9,10 +9,6 @@ const exec = promisify(_exec);
const regex = /https?:\/\/[\w\S(\.|:|/)]+/gi;
console.log(
lib.calcSpeed(123456, 56432)
);
export default async bot => {
return [{
@@ -27,8 +23,14 @@ export default async bot => {
});
if(links.length === 0)
return false;
if(e.message.match(/(!|-)ignore/))
return false;
e.reply(`parsing ${links.length} link${links.length > 1 ? "s" : ""}...`);
if(!e.channel.includes("f0ck") && !e.message.match(/(!|-)f0ck/i))
return false;
//e.reply(`parsing ${links.length} link${links.length > 1 ? "s" : ""}...`);
links.forEach(async link => {
// check repost (link)
@@ -44,6 +46,8 @@ export default async bot => {
const filename = `${uuid}.${meta.ext}`;
e.reply(`downloading ${filename}...`);
// download data
const start = new Date();
const source = (await exec(`youtube-dl "${link}" --max-filesize 10000m -o ./tmp/${filename}`)).stdout.trim();
@@ -70,7 +74,7 @@ export default async bot => {
const insertq = await sql.query(
"insert into items (src, dest, mime, size, checksum, username, userchannel, usernetwork, stamp, active) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
[ link, filename, mime, size, checksum, e.user.username, e.channel, e.network, ~~(new Date() / 1000), 1 ]
[ link, filename, mime, size, checksum, e.user.nick || e.user.username, e.channel, e.network, ~~(new Date() / 1000), 1 ]
);
// generate thumbnail
@@ -88,8 +92,7 @@ export default async bot => {
e.reply([
`title: ${meta.fulltitle}`,
`size: ${lib.formatSize(size)}`,
`speed: ${lib.calcSpeed(size, end)} (ytdl: ${end})`,
`size: ${lib.formatSize(size)} ${lib.calcSpeed(size, end)} (ytdl: ${end})`,
`link: ${cfg.main.url}/${insertq.insertId}`
]);