From c57828e1520352fc4c57b289e71a314b440ad25c Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 14 May 2020 06:48:03 +0200 Subject: [PATCH 1/5] Updated handbrake preset --- commands/utility/download.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/utility/download.js b/commands/utility/download.js index 56a365d..d26a032 100644 --- a/commands/utility/download.js +++ b/commands/utility/download.js @@ -103,7 +103,7 @@ class DownloadCommand extends Command { const options = { input: `${os.tmpdir()}/${fileName}.${ext}`, output: `${os.tmpdir()}/${fileName}compressed.${ext}`, - preset: 'General/Gmail Small 10 Minutes 288p30' + preset: 'Web/Discord Tiny 5 Minutes 240p30' }; let handbrake = hbjs.spawn(options); From 295acc4ce1de00680fcb91cd503cc014ef268f0d Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 14 May 2020 07:02:51 +0200 Subject: [PATCH 2/5] Update some packages --- package-lock.json | 116 ++++++++++++++++++++++++++++------------------ package.json | 2 +- 2 files changed, 72 insertions(+), 46 deletions(-) diff --git a/package-lock.json b/package-lock.json index d2324be..e5c566e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -71,16 +71,6 @@ "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.5.tgz", "integrity": "sha512-CU1q0UXQUpFNzNB7gufgoisDHP7n+T3tkqTsp3MNUkVJ5+hS3BCvME8uCXAUFlz+6T2FbTCu75A+yQ7HMKqRKw==" }, - "@discordjs/form-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz", - "integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==", - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - } - }, "@discordjs/opus": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/@discordjs/opus/-/opus-0.3.2.tgz", @@ -953,11 +943,11 @@ } }, "ansi-escape-sequences": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-escape-sequences/-/ansi-escape-sequences-4.1.0.tgz", - "integrity": "sha512-dzW9kHxH011uBsidTXd14JXgzye/YLb2LzeKZ4bsgl/Knwx8AtbSFkkGxagdNOoh0DlqHCmfiEjWKBaqjOanVw==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/ansi-escape-sequences/-/ansi-escape-sequences-5.1.2.tgz", + "integrity": "sha512-JcpoVp1W1bl1Qn4cVuiXEhD6+dyXKSOgCn2zlzE8inYgCJCBy1aPnUhlz6I4DFum8D4ovb9Qi/iAjUcGvG2lqw==", "requires": { - "array-back": "^3.0.1" + "array-back": "^4.0.0" } }, "ansi-escapes": { @@ -1019,9 +1009,9 @@ "integrity": "sha1-oMoMvCmltz6Dbuvhy/bF4OTrgvk=" }, "array-back": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/array-back/-/array-back-3.1.0.tgz", - "integrity": "sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==" + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-4.0.1.tgz", + "integrity": "sha512-Z/JnaVEXv+A9xabHzN43FiiiWEE7gPCRXMrVmRm00tWbjZRul1iHm7ECzlyNq1p4a4ATXz+G9FJ3GqGOkOV3fg==" }, "array-equal": { "version": "1.0.0", @@ -1718,6 +1708,13 @@ "find-replace": "^3.0.0", "lodash.camelcase": "^4.3.0", "typical": "^4.0.0" + }, + "dependencies": { + "array-back": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-3.1.0.tgz", + "integrity": "sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==" + } } }, "commander": { @@ -2405,11 +2402,6 @@ "version": "3.9.0", "resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz", "integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=" - }, - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" } } }, @@ -2488,16 +2480,16 @@ } }, "discord-akairo": { - "version": "github:1Computer1/discord-akairo#678ae775c89947fcf77c566e04f9035941c42e0e", + "version": "github:1Computer1/discord-akairo#10cef7efc7a329cb1e0d96d73ccb4b83bc0afa72", "from": "github:1Computer1/discord-akairo#master" }, "discord.js": { - "version": "github:discordjs/discord.js#2583ad5da7db5ab92dfa357909f9c713db0a2981", + "version": "github:discordjs/discord.js#5b9cdc5cd243b1588c285e22b90d92535a30b993", "from": "github:discordjs/discord.js#master", "requires": { "@discordjs/collection": "^0.1.5", - "@discordjs/form-data": "^3.0.1", "abort-controller": "^3.0.0", + "form-data": "^3.0.0", "node-fetch": "^2.6.0", "prism-media": "^1.2.0", "setimmediate": "^1.0.5", @@ -2505,6 +2497,16 @@ "ws": "^7.2.1" }, "dependencies": { + "form-data": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz", + "integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + }, "ws": { "version": "7.3.0", "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.0.tgz", @@ -2669,7 +2671,7 @@ } }, "erlpack": { - "version": "github:discordapp/erlpack#c514d36ec81a7a61ef90b75df261025ab046574d", + "version": "github:discordapp/erlpack#5d0064f9e106841e1eead711a6451f99b0d289fd", "from": "github:discordapp/erlpack", "requires": { "bindings": "^1.5.0", @@ -3340,6 +3342,13 @@ "integrity": "sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ==", "requires": { "array-back": "^3.0.1" + }, + "dependencies": { + "array-back": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-3.1.0.tgz", + "integrity": "sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==" + } } }, "find-up": { @@ -4227,17 +4236,27 @@ } }, "handbrake-js": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/handbrake-js/-/handbrake-js-3.0.8.tgz", - "integrity": "sha512-1eWxlN/9ACCkgiCM5OXyL32Howb8KZj9ftxlsijUDztl4ieNeZ04EZ5zc6+uBviFVV7yoqz6ycj2vLxWD/EfBA==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/handbrake-js/-/handbrake-js-5.0.0.tgz", + "integrity": "sha512-NtmYKTVAWxrCwKBJ4j/952bKneBWfOzJ6vMxPoEl2MqAgHrNZOWlRT67f7ftfZ8X2S1GsrZ1AgfMdkaDYx8QcA==", "requires": { - "ansi-escape-sequences": "^4.0.1", - "command-line-args": "^5.0.2", + "ansi-escape-sequences": "^5.1.2", + "command-line-args": "^5.1.1", "decompress": "^4.2.0", - "node-version-matches": "^1.0.1", - "object-to-spawn-args": "^1.1.1", + "node-version-matches": "^2.0.1", + "object-to-spawn-args": "^2.0.0", "request": "^2.88.0", - "rimraf": "^2.6.2" + "rimraf": "^3.0.0" + }, + "dependencies": { + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "requires": { + "glob": "^7.1.3" + } + } } }, "handlebars": { @@ -5495,11 +5514,18 @@ } }, "node-version-matches": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/node-version-matches/-/node-version-matches-1.0.1.tgz", - "integrity": "sha512-L1GRq9vkwvJkOdJynEph63N1gNdKRsThm6CkLn+8X9mFzmDv63iEMkZETVkcWVJowpqK72lNVuMZmeenhDoRhw==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/node-version-matches/-/node-version-matches-2.0.1.tgz", + "integrity": "sha512-oqk6+05FC0dNVY5NuXuhPEMq+m1b9ZjS9SIhVE9EjwCHZspnmjSO8npbKAEieinR8GeEgbecoQcYIvI/Kwcf6Q==", "requires": { - "semver": "^5.6.0" + "semver": "^6.3.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" + } } }, "nopt": { @@ -5648,9 +5674,9 @@ "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" }, "object-to-spawn-args": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object-to-spawn-args/-/object-to-spawn-args-1.1.1.tgz", - "integrity": "sha1-d9qIJ/Bz0BHJ4bFz+JV4FHAkZ4U=" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/object-to-spawn-args/-/object-to-spawn-args-2.0.0.tgz", + "integrity": "sha512-ZMT4owlXg3JGegecLlAgAA/6BsdKHn63R3ayXcAa3zFkF7oUBHcSb0oxszeutYe0FO2c1lT5pwCuidLkC4Gx3g==" }, "object.assign": { "version": "4.1.0", @@ -7792,9 +7818,9 @@ } }, "unbzip2-stream": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.3.3.tgz", - "integrity": "sha512-fUlAF7U9Ah1Q6EieQ4x4zLNejrRvDWUYmxXUpN3uziFYCHapjWFaCAnreY9bGgxzaMCFAPPpYNng57CypwJVhg==", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.2.tgz", + "integrity": "sha512-pZMVAofMrrHX6Ik39hCk470kulCbmZ2SWfQLPmTWqfJV/oUm0gn1CblvHdUu4+54Je6Jq34x8kY6XjTy6dMkOg==", "requires": { "buffer": "^5.2.1", "through": "^2.3.8" @@ -8106,7 +8132,7 @@ } }, "ytpplus-node": { - "version": "git+https://git@github.com/loicbersier/ytpplus-node.git#cd8c7bb893a16625b6c6150489206498377c1f1a", + "version": "git+https://git@github.com/loicbersier/ytpplus-node.git#a9edb7a9596734d0b518cb32e1581f06ce5f7ad7", "from": "git+https://git@github.com/loicbersier/ytpplus-node.git", "requires": { "ffmpeg-static": "^2.4.0", diff --git a/package.json b/package.json index 1876847..b32dfed 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "fluent-ffmpeg": "^2.1.2", "gm": "^1.23.1", "grpc": "^1.24.1", - "handbrake-js": "^3.0.8", + "handbrake-js": "^5.0.0", "jimp": "^0.10.3", "libsodium-wrappers": "^0.7.6", "md5-file": "^5.0.0", From 18193e1b782de6858b55054a8cd21a31b1099d8f Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 14 May 2020 17:01:19 +0200 Subject: [PATCH 3/5] Better error message for HTTP ERROR 429 --- commands/fun/ytp.js | 6 +++++- commands/utility/download.js | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/commands/fun/ytp.js b/commands/fun/ytp.js index 7af3832..0ce78c0 100644 --- a/commands/fun/ytp.js +++ b/commands/fun/ytp.js @@ -137,7 +137,11 @@ class ytpCommand extends Command { if (err) { console.error(err); loadingmsg.delete(); - return message.channel.send('An error has occured, I can\'t download from the link you provided. Is it an mp4?'); + if (err.includes('HTTP Error 429')) { + return message.channel.send('An error has occured, I can\'t download from the link you provided because the website has blocked the bot. Please try again later or upload that video as mp4 on another website.'); + } else { + return message.channel.send('An error has occured, I can\'t download from the link you provided. Is it an mp4?'); + } } else { if (output[2]) { if (output[2].includes('File is larger than max-filesize')) { diff --git a/commands/utility/download.js b/commands/utility/download.js index d26a032..2e962b8 100644 --- a/commands/utility/download.js +++ b/commands/utility/download.js @@ -76,8 +76,11 @@ class DownloadCommand extends Command { if (err) { console.error(err); loadingmsg.delete(); - return message.channel.send('An error has occured, I can\'t download from the link you provided.'); - } + if (err.includes('HTTP Error 429')) { + return message.channel.send('An error has occured, I can\'t download from the link you provided because the website has blocked the bot. Please try again later.'); + } else { + return message.channel.send('An error has occured, I can\'t download from the link you provided.'); + } } let ext = 'mp4'; From 1bbe7702d3c7cfca35595b8672f3a0e8450eb630 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 14 May 2020 17:08:04 +0200 Subject: [PATCH 4/5] Actually show better errors --- commands/fun/ytp.js | 4 ++-- commands/utility/download.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commands/fun/ytp.js b/commands/fun/ytp.js index 0ce78c0..7f9372a 100644 --- a/commands/fun/ytp.js +++ b/commands/fun/ytp.js @@ -135,9 +135,9 @@ class ytpCommand extends Command { return youtubedl.exec(url, ['--rm-cache-dir', '--no-playlist', '--max-filesize', '50m', '--format=mp4', '-o', `./asset/ytp/userVid/${message.id}.mp4`], {}, async function(err, output) { console.log(output); if (err) { - console.error(err); + console.error(err.toString()); loadingmsg.delete(); - if (err.includes('HTTP Error 429')) { + if (err.toString().includes('HTTP Error 429')) { return message.channel.send('An error has occured, I can\'t download from the link you provided because the website has blocked the bot. Please try again later or upload that video as mp4 on another website.'); } else { return message.channel.send('An error has occured, I can\'t download from the link you provided. Is it an mp4?'); diff --git a/commands/utility/download.js b/commands/utility/download.js index 2e962b8..7dce8b6 100644 --- a/commands/utility/download.js +++ b/commands/utility/download.js @@ -74,9 +74,9 @@ class DownloadCommand extends Command { } return youtubedl.exec(link, ['--rm-cache-dir', '-o', `${os.tmpdir()}/${fileName}`], {}, async function(err) { if (err) { - console.error(err); + console.error(err.toString()); loadingmsg.delete(); - if (err.includes('HTTP Error 429')) { + if (err.toString().includes('HTTP Error 429')) { return message.channel.send('An error has occured, I can\'t download from the link you provided because the website has blocked the bot. Please try again later.'); } else { return message.channel.send('An error has occured, I can\'t download from the link you provided.'); From 9b6f2b467a466f92ae8da972228e91aa02fa4114 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Thu, 14 May 2020 17:44:48 +0200 Subject: [PATCH 5/5] added support for error 403 --- commands/fun/ytp.js | 2 +- commands/utility/download.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/fun/ytp.js b/commands/fun/ytp.js index 7f9372a..b9e7a6f 100644 --- a/commands/fun/ytp.js +++ b/commands/fun/ytp.js @@ -137,7 +137,7 @@ class ytpCommand extends Command { if (err) { console.error(err.toString()); loadingmsg.delete(); - if (err.toString().includes('HTTP Error 429')) { + if (err.toString().includes('HTTP Error 429') || err.toString().includes('HTTP Error 403')) { return message.channel.send('An error has occured, I can\'t download from the link you provided because the website has blocked the bot. Please try again later or upload that video as mp4 on another website.'); } else { return message.channel.send('An error has occured, I can\'t download from the link you provided. Is it an mp4?'); diff --git a/commands/utility/download.js b/commands/utility/download.js index 7dce8b6..24c8d59 100644 --- a/commands/utility/download.js +++ b/commands/utility/download.js @@ -76,7 +76,7 @@ class DownloadCommand extends Command { if (err) { console.error(err.toString()); loadingmsg.delete(); - if (err.toString().includes('HTTP Error 429')) { + if (err.toString().includes('HTTP Error 429') || err.toString().includes('HTTP Error 403')) { return message.channel.send('An error has occured, I can\'t download from the link you provided because the website has blocked the bot. Please try again later.'); } else { return message.channel.send('An error has occured, I can\'t download from the link you provided.');