1
0
Code Issues Pull Requests Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
程序员小墨 2022-10-01 23:27:52 +08:00
parent 3dcb71b5a3
commit 3e1ef431a7
5 changed files with 9 additions and 11 deletions

View File

@ -13,7 +13,7 @@ global.dbUtils = dbUtils;
console.log("global.useMysqlPool:", !!global.useMysqlPool); console.log("global.useMysqlPool:", !!global.useMysqlPool);
// 两次请求之间停顿时间 // 两次请求之间停顿时间
global.sleepTime = 10; global.sleepTime = 100;
// 引入utils // 引入utils
const songInfoUtils = require('./src/getInfo/songInfoUtils'); const songInfoUtils = require('./src/getInfo/songInfoUtils');
@ -29,8 +29,6 @@ async function test() {
// 不是所有歌手都有个人主页 例如 https://music.163.com/#/artist?id=1079075 // 不是所有歌手都有个人主页 例如 https://music.163.com/#/artist?id=1079075
let res = await global.statistics();
// let res = await albumInfoUtils.fetch({ albumId: "9156", debug: true }); // let res = await albumInfoUtils.fetch({ albumId: "9156", debug: true });
// let res = await artistInfoUtils.fetch({ artistId: "12023508" }); // let res = await artistInfoUtils.fetch({ artistId: "12023508" });
// let res = await songInfoUtils.fetch({ songId: "437608327" }); // let res = await songInfoUtils.fetch({ songId: "437608327" });
@ -47,7 +45,6 @@ async function test() {
*/ */
async function main() { async function main() {
console.log("neteaseMusic Starting..."); console.log("neteaseMusic Starting...");
console.log(`数据统计: ${await statistics()}`);
while (true) { while (true) {
// 删除脏数据 // 删除脏数据
@ -68,7 +65,6 @@ async function main() {
*/ */
async function update() { async function update() {
console.log("neteaseMusic update ..."); console.log("neteaseMusic update ...");
console.log(`数据统计: ${await statistics()}`);
let sleepTime = 100; let sleepTime = 100;
@ -94,7 +90,9 @@ async function update() {
/** /**
* 统计数据库中数据 * 统计数据库中数据
*/ */
global.statistics = async function () { updateStatisticsResult();
setInterval(updateStatisticsResult, 1000);
async function updateStatisticsResult() {
let sql = ` let sql = `
SELECT SELECT
song_count, song_count,
@ -144,7 +142,7 @@ global.statistics = async function () {
let songAlbumCount = result[0].song_album_count; let songAlbumCount = result[0].song_album_count;
let songArtistCount = result[0].song_artist_count; let songArtistCount = result[0].song_artist_count;
return [ global.statistics = [
`song: ${songCount}/${songCount + songWaiting}`, `song: ${songCount}/${songCount + songWaiting}`,
`album: ${albumCount}/${albumCount + albumWaiting}`, `album: ${albumCount}/${albumCount + albumWaiting}`,
`artist: ${artistCount}/${artistCount + artistWaiting}`, `artist: ${artistCount}/${artistCount + artistWaiting}`,

View File

@ -31,7 +31,7 @@ async function fetchAll() {
for (let i = 0; i < albumIds.length; i++) { for (let i = 0; i < albumIds.length; i++) {
await global.checkIsExit(); await global.checkIsExit();
const albumId = albumIds[i]; const albumId = albumIds[i];
console.log(`${i}/${albumIds.length} | album: ${albumId} | ${await global.statistics()}`); console.log(`${i}/${albumIds.length} | album: ${albumId} | ${global.statistics}`);
try { try {
await fetch({ albumId: albumId }); await fetch({ albumId: albumId });
} catch (err) { } catch (err) {

View File

@ -31,7 +31,7 @@ async function fetchAll() {
for (let i = 0; i < artistIds.length; i++) { for (let i = 0; i < artistIds.length; i++) {
await global.checkIsExit(); await global.checkIsExit();
const artistId = artistIds[i]; const artistId = artistIds[i];
console.log(`${i}/${artistIds.length} | artist: ${artistId} | ${await global.statistics()}`); console.log(`${i}/${artistIds.length} | artist: ${artistId} | ${global.statistics}`);
try { try {
await fetch({ artistId: artistId }); await fetch({ artistId: artistId });
} catch (err) { } catch (err) {

View File

@ -16,7 +16,7 @@ async function fetchAll() {
for (let i = 0; i < songIds.length; i++) { for (let i = 0; i < songIds.length; i++) {
await global.checkIsExit(); await global.checkIsExit();
const songId = songIds[i]; const songId = songIds[i];
console.log(`${i}/${songIds.length} | lyric: ${songId} | ${await global.statistics()}`); console.log(`${i}/${songIds.length} | lyric: ${songId} | ${global.statistics}`);
try { try {
await fetch({ songId: songId }); await fetch({ songId: songId });
} catch (err) { } catch (err) {

View File

@ -35,7 +35,7 @@ async function fetchAll() {
for (let i = 0; i < songIds.length; i++) { for (let i = 0; i < songIds.length; i++) {
await global.checkIsExit(); await global.checkIsExit();
const songId = songIds[i]; const songId = songIds[i];
console.log(`${i}/${songIds.length} | song: ${songId} | ${await global.statistics()}`); console.log(`${i}/${songIds.length} | song: ${songId} | ${global.statistics}`);
try { try {
await fetch({ songId: songId }); await fetch({ songId: songId });
} catch (err) { } catch (err) {