diff --git a/netease_music/index.js b/netease_music/index.js index ced6442..e82ef89 100644 --- a/netease_music/index.js +++ b/netease_music/index.js @@ -26,15 +26,14 @@ async function main() { // getUserInfo({ userId: "29879272" }); while (true) { - await startGetMusic(100); + // 删除脏数据 + var affectRows1 = await dbUtils.query(`DELETE FROM song_artist_relation WHERE song_id = 0 OR artist_id = 0`, []); + var affectRows2 = await dbUtils.query(`DELETE FROM song_album_relation WHERE song_id = 0 OR album_id = 0`, []); + console.log(affectRows1.affectedRows, affectRows2.affectedRows); + await startGetMusic(1); } } -/* -DELETE FROM song_artist_relation WHERE song_id = 0 OR artist_id = 0 --- DELETE FROM song_album_relation WHERE song_id = 0 OR album_id = 0 - */ - async function startGetMusic(sleepTime) { // 从数据库中查出还缺少的歌曲,并进行爬取 @@ -138,7 +137,7 @@ async function getMusicInfo({ songId }) { try { // var html = fs.readFileSync(path.join(__dirname, "../temp", `song-${songId}.html`), 'utf8'); var html = await requestUtils.getApiResult(url); - fs.writeFileSync(path.join(__dirname, "../temp", `song-${songId}.html`), html); + // fs.writeFileSync(path.join(__dirname, "../temp", `song-${songId}.html`), html); } catch (errors) { console.error(errors); return; @@ -224,7 +223,7 @@ async function getArtistInfo({ artistId }) { try { // 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; @@ -290,7 +289,7 @@ async function getAlbumInfo({ albumId }) { try { // var html = fs.readFileSync(path.join(__dirname, "../temp", `album-${albumId}.html`), 'utf8'); var html = await requestUtils.getApiResult(url); - fs.writeFileSync(path.join(__dirname, "../temp", `album-${albumId}.html`), html); + // fs.writeFileSync(path.join(__dirname, "../temp", `album-${albumId}.html`), html); } catch (errors) { console.error(errors); return;