1
0
Code Issues Pull Requests Projects Releases Wiki Activity GitHub Gitee

从数据库中取得id之后打印出来

This commit is contained in:
2022-11-09 11:18:54 +08:00
parent e48305ffaa
commit 8e0406a485
6 changed files with 33 additions and 13 deletions

View File

@@ -30,6 +30,7 @@ SELECT * FROM album WHERE (full_description = '' or full_description is null) an
async function fetchAll({ args = {}, isUpdate = false }) {
console.log("start fetching albums ...");
let albumIds = await dataManager.album.getIdsToFetch(args, isUpdate);
console.log(`albumIds was fetched, count: ${albumIds.length}`);
for (let i = 0; i < albumIds.length; i++) {
await global.checkIsExit();
const albumId = albumIds[i];

View File

@@ -26,6 +26,7 @@ async function getFromDatabase({ artistId }) {
async function fetchAll({ args = {} }) {
console.log("start fetching artists ...");
let artistIds = await dataManager.artist.getIdsToFetch(args);
console.log(`artistIds was fetched, count: ${artistIds.length}`);
for (let i = 0; i < artistIds.length; i++) {
await global.checkIsExit();
const artistId = artistIds[i];

View File

@@ -20,6 +20,7 @@ async function fetchAll({ args = {} }) {
// SELECT song_id FROM wait_fetch_comment WHERE song_id NOT IN ( SELECT song_id FROM comment_progress )
// `, []);
let songIds = await dataManager.comment.getIdsToFetch(args);
console.log(`songIds was fetched, count: ${songIds.length}`);
for (let i = 0; i < songIds.length; i++) {
await global.checkIsExit();
const songId = songIds[i];

View File

@@ -11,6 +11,7 @@ const dbUtils = global.dbUtils;
async function fetchAll({ args = {} }) {
console.log("start fetching lyrics ...");
let songIds = await dataManager.lyric.getIdsToFetch(args);
console.log(`songIds was fetched, count: ${songIds.length}`);
for (let i = 0; i < songIds.length; i++) {
await global.checkIsExit();
const songId = songIds[i];

View File

@@ -14,6 +14,7 @@ const { song_detail } = require('NeteaseCloudMusicApi');
async function fetchAll({ args = {} }) {
console.log("start fetching songs ...");
let songIds = await dataManager.song.getIdsToFetch(args);
console.log(`songIds was fetched, count: ${songIds.length}`);
// 0 - 100, 200 - 399, 400 - ..., ... - songIds.length-1
// 0 1 2 count-1
var step = 1000;
@@ -23,6 +24,10 @@ async function fetchAll({ args = {} }) {
await global.checkIsExit();
var subArray = songIds.slice(i * step, (i + 1) * step);
console.log(`${i + 1}/${count} | song: ${fill(subArray[0], 10)}-${fill(subArray.slice(-1)[0], 10)} ${fill(`(${subArray.length})`, 6, ' ', true)} | ${args.min || "?"}-${args.max || "?"}`);
if (subArray.length < 800) {
console.log("小于800首歌等待凑够800首歌下次一起爬取");
return;
}
try {
await fetch({ songIdArray: subArray });
} catch (err) {