From 1ee36570939d91bf3b8bd156391e8b1f702af3d5 Mon Sep 17 00:00:00 2001 From: RemixDev Date: Sat, 5 Jun 2021 18:41:13 +0200 Subject: [PATCH] Added better logging for itemgen errors --- package.json | 2 +- server/dist/main.js | 19 ++++++++++++++++--- server/package.json | 2 +- server/src/main.ts | 19 +++++++++++++++---- server/yarn.lock | 8 ++++---- yarn.lock | 8 ++++---- 6 files changed, 41 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 8345cca..aa210f9 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "cookie-parser": "1.4.5", "debug": "2.6.9", - "deemix": "^0.1.3", + "deemix": "^0.1.4", "deezer-js": "^1.0.0", "dotenv": "8.2.0", "express": "4.17.1", diff --git a/server/dist/main.js b/server/dist/main.js index 84cebcb..a6d227e 100644 --- a/server/dist/main.js +++ b/server/dist/main.js @@ -79,6 +79,7 @@ function addToQueue(dz, url, bitrate) { if (!dz.logged_in) throw new errors_1.NotLoggedIn(); let downloadObjs = []; + const downloadErrors = []; let link = ''; const requestUUID = uuid_1.v4(); if (url.length > 1) { @@ -87,13 +88,25 @@ function addToQueue(dz, url, bitrate) { for (let i = 0; i < url.length; i++) { link = url[i]; console.log(`Adding ${link} to queue`); - const downloadObj = yield deemix_1.default.generateDownloadObject(dz, link, bitrate, exports.plugins, exports.listener); + let downloadObj; + try { + downloadObj = yield deemix_1.default.generateDownloadObject(dz, link, bitrate, exports.plugins, exports.listener); + } + catch (e) { + downloadErrors.push(e); + } if (Array.isArray(downloadObj)) { downloadObjs = downloadObjs.concat(downloadObj); } - else { + else if (downloadObj) downloadObjs.push(downloadObj); - } + } + if (downloadErrors.length) { + downloadErrors.forEach((e) => { + if (!e.errid) + console.trace(e); + exports.listener.send('queueError', { link: e.link, error: e.message, errid: e.errid }); + }); } if (url.length > 1) { exports.listener.send('finishGeneratingItems', { uuid: requestUUID, total: downloadObjs.length }); diff --git a/server/package.json b/server/package.json index f32dcb3..ee4be59 100644 --- a/server/package.json +++ b/server/package.json @@ -15,7 +15,7 @@ "dependencies": { "cookie-parser": "1.4.5", "debug": "2.6.9", - "deemix": "^0.1.3", + "deemix": "^0.1.4", "deezer-js": "^1.0.0", "dotenv": "8.2.0", "express": "4.17.1", diff --git a/server/src/main.ts b/server/src/main.ts index e52c87d..83465a7 100644 --- a/server/src/main.ts +++ b/server/src/main.ts @@ -68,6 +68,7 @@ export async function addToQueue(dz: any, url: string[], bitrate: number) { if (!dz.logged_in) throw new NotLoggedIn() let downloadObjs: any[] = [] + const downloadErrors: any[] = [] let link: string = '' const requestUUID = uuidv4() @@ -78,12 +79,22 @@ export async function addToQueue(dz: any, url: string[], bitrate: number) { for (let i = 0; i < url.length; i++) { link = url[i] console.log(`Adding ${link} to queue`) - const downloadObj = await deemix.generateDownloadObject(dz, link, bitrate, plugins, listener) + let downloadObj + try { + downloadObj = await deemix.generateDownloadObject(dz, link, bitrate, plugins, listener) + } catch (e) { + downloadErrors.push(e) + } if (Array.isArray(downloadObj)) { downloadObjs = downloadObjs.concat(downloadObj) - } else { - downloadObjs.push(downloadObj) - } + } else if (downloadObj) downloadObjs.push(downloadObj) + } + + if (downloadErrors.length) { + downloadErrors.forEach((e: any) => { + if (!e.errid) console.trace(e) + listener.send('queueError', { link: e.link, error: e.message, errid: e.errid }) + }) } if (url.length > 1) { diff --git a/server/yarn.lock b/server/yarn.lock index fe59081..5f6e25c 100644 --- a/server/yarn.lock +++ b/server/yarn.lock @@ -1899,10 +1899,10 @@ decompress-response@^6.0.0: dependencies: mimic-response "^3.1.0" -deemix@^0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/deemix/-/deemix-0.1.3.tgz#fe8a9cdb484ffd5c51d61eadb6d7a508022a9570" - integrity sha512-R0lp1hgxP4Z2kgqtJcBKkOrBIoSt9+C+rjFwQmW+UQSE9Vyzbr0ZYGBgV3qwHDj3mZ3OP+mr22hiTa43tYPSWw== +deemix@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/deemix/-/deemix-0.1.4.tgz#ad43648895fd3bbe5583e7c558f786d6ce43598f" + integrity sha512-7v6zfcx+16g3Ii2yvntJM+MvTYPpWyabzHxRN0u8mUarc/P7o8hPrSVeofAZOhF6iSN0RBKeSjIoN5LTQsobSA== dependencies: async "^3.2.0" browser-id3-writer "^4.4.0" diff --git a/yarn.lock b/yarn.lock index ddbdbb2..1f710f8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -813,10 +813,10 @@ decompress-response@^6.0.0: dependencies: mimic-response "^3.1.0" -deemix@^0.1.3: - version "0.1.3" - resolved "https://registry.yarnpkg.com/deemix/-/deemix-0.1.3.tgz#fe8a9cdb484ffd5c51d61eadb6d7a508022a9570" - integrity sha512-R0lp1hgxP4Z2kgqtJcBKkOrBIoSt9+C+rjFwQmW+UQSE9Vyzbr0ZYGBgV3qwHDj3mZ3OP+mr22hiTa43tYPSWw== +deemix@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/deemix/-/deemix-0.1.4.tgz#ad43648895fd3bbe5583e7c558f786d6ce43598f" + integrity sha512-7v6zfcx+16g3Ii2yvntJM+MvTYPpWyabzHxRN0u8mUarc/P7o8hPrSVeofAZOhF6iSN0RBKeSjIoN5LTQsobSA== dependencies: async "^3.2.0" browser-id3-writer "^4.4.0"