diff --git a/netease_music/src/assistantUtils.js b/netease_music/src/assistantUtils.js index bdd3cad..f8e8cda 100644 --- a/netease_music/src/assistantUtils.js +++ b/netease_music/src/assistantUtils.js @@ -45,7 +45,7 @@ async function migrateIdsFromCheckToFetch(tableName, fieldName, insertSql = null // 从待检查表中删除 if (ids.length > 0) await dbUtils.query(`DELETE FROM wait_check_${tableName} WHERE id IN ?`, [[ids]]); - console.log(`table: ${tableName}\t| ${fill(ids[0], 10)} - ${fill(ids.slice(-1)[0], 10)} ${fill(`(${finalIds.length}/${ids.length})`, 10, ' ', true)}\t| affected: ${result?.affectedRows}`); + console.log(`table: ${tableName}\t| ${fill(ids[0], 10)} - ${fill(ids.slice(-1)[0], 10)} ${fill(`(${finalIds.length}/${ids.length})`, 10, ' ', true)}\t| affected: ${result ? result.affectedRows : ""}`); } } catch (e) { console.error(e); diff --git a/netease_music/src/index.js b/netease_music/src/index.js index 3c12711..6ce33fe 100644 --- a/netease_music/src/index.js +++ b/netease_music/src/index.js @@ -175,7 +175,7 @@ async function watch() { let result = await dbUtils.query(`SELECT \`value\` as count FROM analysis WHERE \`key\`='${sql.name}'`); let sqlTimeSpent = Date.now() - sqlStartTime; sqlsTimeSpent += sqlTimeSpent; - newWatchParam[sql.name] = result[0]?.count; + newWatchParam[sql.name] = result ? result[0].count : undefined; // result[0]?.count 兼容 node 12 console.log(`query ${sql.name} finished.\tspend time: ${sqlTimeSpent}ms (${(sqlTimeSpent / 1000).toFixed(2)}s),\tcount: ${newWatchParam[sql.name]}`); resolve(); })); diff --git a/utils/requestUtils.js b/utils/requestUtils.js index c1d154d..f698e8a 100644 --- a/utils/requestUtils.js +++ b/utils/requestUtils.js @@ -45,7 +45,14 @@ async function getRedirectUrl(url) { reject(err); } // console.log(res.headers.location); - resolve(res?.headers?.location); + + // 兼容 node 12 + // resolve(res?.headers?.location); + if (res && res.headers) { + resolve(res.headers.location); + } else { + resolve(undefined); + } }); }); }