|
|
@@ -130,6 +130,61 @@ async function runAlbumMeta() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+async function runVideoStoryMeta() {
|
|
|
+ let done = 0;
|
|
|
+ let duration = 0;
|
|
|
+ let hour, minute, second;
|
|
|
+ let start = Date.now();
|
|
|
+
|
|
|
+ // 筛选出所有album
|
|
|
+ let query = { enabled: true, $or: [{ seoTitle: { $exists: false } }, { seoTitle: null }] }
|
|
|
+ let docs = await models.ArtVideoStory
|
|
|
+ .find(query)
|
|
|
+ .sort({ order: 'asc' })
|
|
|
+ .select('name');
|
|
|
+
|
|
|
+
|
|
|
+ let total = docs.length;
|
|
|
+ console.log('total:', total);
|
|
|
+ if (total <= 0) return;
|
|
|
+
|
|
|
+ for (let doc of docs) {
|
|
|
+ console.log(`process video-story ${doc._id}`);
|
|
|
+
|
|
|
+ console.time(doc._id);
|
|
|
+
|
|
|
+ try {
|
|
|
+ let text = `帮我生成填色页视频故事《${doc.name}》的SEO title(60个字符以内) 和 description(160个字符以内), 以json格式输出,支持语言中文(zh)、英语(en)、西班牙语(es)、葡萄牙语(pt)、日语(ja),形如: { title: {zh:'', en:'', es: '', pt: '', ja: ''}, description: {zh:'', en:'', es: '', pt: '', ja: ''}`;
|
|
|
+ let metaInfo = await fetchMetaByTxtFromDoubao(text);
|
|
|
+ console.log(metaInfo);
|
|
|
+ let metaInfoJson = JSON.parse(metaInfo);
|
|
|
+ let titleJson = metaInfoJson.title;
|
|
|
+ let descJson = metaInfoJson.description;
|
|
|
+ let title = JSON.stringify(titleJson);
|
|
|
+ let desc = JSON.stringify(descJson);
|
|
|
+
|
|
|
+ doc.seoTitle = title;
|
|
|
+ doc.seoDescription = desc;
|
|
|
+ await doc.save();
|
|
|
+
|
|
|
+ } catch (e) {
|
|
|
+ console.error(e.message);
|
|
|
+ }
|
|
|
+
|
|
|
+ console.timeEnd(doc._id);
|
|
|
+
|
|
|
+ done++;
|
|
|
+ duration = (Date.now() - start) / 1000;
|
|
|
+ hour = (Math.floor(duration / 60 / 60)).toString().padStart(2, '0');
|
|
|
+ minute = (Math.floor(duration / 60) % 60).toString().padStart(2, '0');
|
|
|
+ second = (Math.floor(duration) % 60).toString().padStart(2, '0');
|
|
|
+
|
|
|
+ console.log('progress: ' + Math.floor((100 * done / total)) + '% used time: ' + hour + ':' + minute + ':' + second);
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
async function runArtMeta() {
|
|
|
let done = 0;
|
|
|
let duration = 0;
|
|
|
@@ -194,6 +249,7 @@ async function runArtMeta() {
|
|
|
|
|
|
async function run() {
|
|
|
await runAlbumMeta();
|
|
|
+ await runVideoStoryMeta();
|
|
|
await runArtMeta();
|
|
|
}
|
|
|
|