update
This commit is contained in:
parent
b85653ec72
commit
7004fe8858
@ -26,15 +26,14 @@ async function main() {
|
|||||||
// getUserInfo({ userId: "29879272" });
|
// getUserInfo({ userId: "29879272" });
|
||||||
|
|
||||||
while (true) {
|
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) {
|
async function startGetMusic(sleepTime) {
|
||||||
|
|
||||||
// 从数据库中查出还缺少的歌曲,并进行爬取
|
// 从数据库中查出还缺少的歌曲,并进行爬取
|
||||||
@ -138,7 +137,7 @@ async function getMusicInfo({ songId }) {
|
|||||||
try {
|
try {
|
||||||
// var html = fs.readFileSync(path.join(__dirname, "../temp", `song-${songId}.html`), 'utf8');
|
// var html = fs.readFileSync(path.join(__dirname, "../temp", `song-${songId}.html`), 'utf8');
|
||||||
var html = await requestUtils.getApiResult(url);
|
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) {
|
} catch (errors) {
|
||||||
console.error(errors);
|
console.error(errors);
|
||||||
return;
|
return;
|
||||||
@ -224,7 +223,7 @@ async function getArtistInfo({ artistId }) {
|
|||||||
try {
|
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);
|
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) {
|
} catch (errors) {
|
||||||
console.error(errors);
|
console.error(errors);
|
||||||
return;
|
return;
|
||||||
@ -290,7 +289,7 @@ async function getAlbumInfo({ albumId }) {
|
|||||||
try {
|
try {
|
||||||
// var html = fs.readFileSync(path.join(__dirname, "../temp", `album-${albumId}.html`), 'utf8');
|
// var html = fs.readFileSync(path.join(__dirname, "../temp", `album-${albumId}.html`), 'utf8');
|
||||||
var html = await requestUtils.getApiResult(url);
|
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) {
|
} catch (errors) {
|
||||||
console.error(errors);
|
console.error(errors);
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user