|
|
@@ -72,31 +72,25 @@ async function fetchMetaFromDoubao(imageUrl) {
|
|
|
|
|
|
|
|
|
async function run() {
|
|
|
+
|
|
|
let done = 0;
|
|
|
let duration = 0;
|
|
|
let hour, minute, second;
|
|
|
let start = Date.now();
|
|
|
|
|
|
+
|
|
|
// 筛选出所有已经ready并且还没有title的图
|
|
|
let query = { status: { $gte: 7000 }, $or: [{ copy: { $exists: false } }, { copy: null }] };
|
|
|
+ let docs = await models.Art.find(query).limit(1000).sort({ publishTime: 'desc' }); // 内存有限,每次跑1000个
|
|
|
+
|
|
|
|
|
|
- let total = await models.Art.countDocuments(query);
|
|
|
+ let total = docs.length;
|
|
|
console.log('total:', total);
|
|
|
+ if (total <= 0) return;
|
|
|
|
|
|
- models.Art
|
|
|
- .find(query)
|
|
|
- .sort({ publishTime: 'desc' })
|
|
|
- .cursor()
|
|
|
- .eachAsync(job)
|
|
|
- .catch(err => {
|
|
|
- console.error(err.message);
|
|
|
- // 出错重试
|
|
|
- run();
|
|
|
- })
|
|
|
- // .then(() => require('process').exit(0))
|
|
|
-
|
|
|
- async function job(doc) {
|
|
|
+ for (let doc of docs) {
|
|
|
console.log(`process ${doc._id}`);
|
|
|
+
|
|
|
let thumbUrl = `${config.resHost}/thumbs/v2/work/320/${doc._id}.png`;
|
|
|
if (doc.hasSpecial) {
|
|
|
thumbUrl = `${config.resHost}/thumbs/v2/special/320/${doc._id}.png`;
|
|
|
@@ -136,6 +130,8 @@ async function run() {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ run();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|