Added better logging for itemgen errors

This commit is contained in:
RemixDev 2021-06-05 18:41:13 +02:00
parent 6dbbe7c55f
commit 1ee3657093
6 changed files with 41 additions and 17 deletions

View File

@ -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",

17
server/dist/main.js vendored
View File

@ -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 });

View File

@ -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",

View File

@ -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) {

View File

@ -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"

View File

@ -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"