1
0
Code Issues Pull Requests Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-10-01 16:16:39 +08:00
parent 37fe49c53c
commit 64834ae7f9
9 changed files with 35 additions and 27 deletions

View File

@@ -6,7 +6,7 @@ const requestUtils = require('../../../utils/requestUtils');
const sleepUtils = require('../../../utils/sleepUtils');
// 获取音乐人详情
async function get({ artistId }) {
async function fetch({ artistId }) {
let result = await dbUtils.query('SELECT count(*) as count FROM artist WHERE artist_id = ?', [artistId]);
if (result[0].count > 0) {
console.log(`数据库中已有数据,跳过 artistId: ${artistId}`);
@@ -25,9 +25,9 @@ async function get({ artistId }) {
let url = `https://music.163.com/artist?id=${artistId}`;
try {
// var html = fs.readFileSync(path.join(__dirname, "../temp", `artist-${artistId}.html`), 'utf8');
// var html = fs.readFileSync(path.join(__dirname, "../../temp", `artist-${artistId}.html`), 'utf8');
var html = await requestUtils.getApiResult(url);
// fs.writeFileSync(path.join(__dirname, "../temp", `artist-${artistId}.html`), html);
// fs.writeFileSync(path.join(__dirname, "../../temp", `artist-${artistId}.html`), html);
} catch (errors) {
console.error(errors);
return;
@@ -78,5 +78,5 @@ async function get({ artistId }) {
}
module.exports = {
get: get,
fetch: fetch,
}