1
This commit is contained in:
@@ -29,7 +29,6 @@ async function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function startGetMusic({ songId }) {
|
async function startGetMusic({ songId }) {
|
||||||
await sleepUtils.sleep(500);
|
|
||||||
var songInfo = await getMusicInfo({ songId: songId });
|
var songInfo = await getMusicInfo({ songId: songId });
|
||||||
|
|
||||||
var albumInfo = await getAlbumInfo({ albumId: songInfo.albumId });
|
var albumInfo = await getAlbumInfo({ albumId: songInfo.albumId });
|
||||||
@@ -52,11 +51,24 @@ async function startGetMusic({ songId }) {
|
|||||||
// 获取音乐详情
|
// 获取音乐详情
|
||||||
async function getMusicInfo({ songId }) {
|
async function getMusicInfo({ songId }) {
|
||||||
console.log(`开始处理 song: ${songId}`);
|
console.log(`开始处理 song: ${songId}`);
|
||||||
// let result = await dbUtils.query('SELECT count(*) as count FROM song WHERE song_id = ?', [songId]);
|
let result = await dbUtils.query('SELECT count(*) as count FROM song WHERE song_id = ?', [songId]);
|
||||||
// if (result[0].count > 0) {
|
if (result[0].count > 0) {
|
||||||
// console.log(`数据库中已有数据,跳过 songId: ${songId}`);
|
console.log(`数据库中已有数据,跳过 songId: ${songId}`);
|
||||||
// return;
|
let songResult = await dbUtils.query('SELECT * FROM song WHERE song_id = ?', [songId]);
|
||||||
// }
|
songResult = JSON.parse(JSON.stringify(songResult));
|
||||||
|
|
||||||
|
let songArtistResult = await dbUtils.query('SELECT * FROM song_artist_relation WHERE song_id = ?', [songId]);
|
||||||
|
songArtistResult = JSON.parse(JSON.stringify(songArtistResult));
|
||||||
|
songResult.artistIds = songArtistResult.map(song => song.artist_id);
|
||||||
|
|
||||||
|
let songAlbumResult = await dbUtils.query('SELECT * FROM song_album_relation WHERE song_id = ?', [songId]);
|
||||||
|
songAlbumResult = JSON.parse(JSON.stringify(songAlbumResult));
|
||||||
|
songResult.albumId = songAlbumResult.map(song => song.album_id)[0];
|
||||||
|
|
||||||
|
// console.log(songResult);
|
||||||
|
return songResult;
|
||||||
|
}
|
||||||
|
await sleepUtils.sleep(500);
|
||||||
|
|
||||||
let url = `https://music.163.com/song?id=${songId}`;
|
let url = `https://music.163.com/song?id=${songId}`;
|
||||||
|
|
||||||
@@ -126,8 +138,17 @@ async function getArtistInfo({ artistId }) {
|
|||||||
let result = await dbUtils.query('SELECT count(*) as count FROM artist WHERE artist_id = ?', [artistId]);
|
let result = await dbUtils.query('SELECT count(*) as count FROM artist WHERE artist_id = ?', [artistId]);
|
||||||
if (result[0].count > 0) {
|
if (result[0].count > 0) {
|
||||||
console.log(`数据库中已有数据,跳过 artistId: ${artistId}`);
|
console.log(`数据库中已有数据,跳过 artistId: ${artistId}`);
|
||||||
return;
|
// // let artistResult = await dbUtils.query('SELECT * FROM artist LEFT JOIN song_artist_relation ON artist.artist_id = song_artist_relation.artist_id WHERE artist.artist_id = ?', [artistId]);
|
||||||
|
// let artistResult = await dbUtils.query('SELECT * FROM artist WHERE artist_id = ?', [artistId]);
|
||||||
|
// artistResult = JSON.parse(JSON.stringify(artistResult));
|
||||||
|
// let songArtistResult = await dbUtils.query('SELECT * FROM song_artist_relation WHERE artist_id = ?', [artistId]);
|
||||||
|
// songArtistResult = JSON.parse(JSON.stringify(songArtistResult));
|
||||||
|
// artistResult.songIds = songArtistResult.map(song => song.song_id);
|
||||||
|
// // console.log(artistResult);
|
||||||
|
// return artistResult;
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
await sleepUtils.sleep(500);
|
||||||
|
|
||||||
let url = `https://music.163.com/artist?id=${artistId}`;
|
let url = `https://music.163.com/artist?id=${artistId}`;
|
||||||
|
|
||||||
@@ -182,8 +203,16 @@ async function getAlbumInfo({ albumId }) {
|
|||||||
let result = await dbUtils.query('SELECT count(*) as count FROM album WHERE album_id = ?', [albumId]);
|
let result = await dbUtils.query('SELECT count(*) as count FROM album WHERE album_id = ?', [albumId]);
|
||||||
if (result[0].count > 0) {
|
if (result[0].count > 0) {
|
||||||
console.log(`数据库中已有数据,跳过 albumId: ${albumId}`);
|
console.log(`数据库中已有数据,跳过 albumId: ${albumId}`);
|
||||||
return;
|
// let albumResult = await dbUtils.query('SELECT * FROM album WHERE album_id = ?', [albumId]);
|
||||||
|
// albumResult = JSON.parse(JSON.stringify(albumResult));
|
||||||
|
// let songAlbumResult = await dbUtils.query('SELECT * FROM song_album_relation WHERE album_id = ?', [albumId]);
|
||||||
|
// songAlbumResult = JSON.parse(JSON.stringify(songAlbumResult));
|
||||||
|
// albumResult.songIds = songAlbumResult.map(song => song.song_id);
|
||||||
|
// // console.log(albumResult);
|
||||||
|
// return albumResult;
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
await sleepUtils.sleep(500);
|
||||||
|
|
||||||
let url = `https://music.163.com/album?id=${albumId}`;
|
let url = `https://music.163.com/album?id=${albumId}`;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user