904118851 8 сар өмнө
parent
commit
c01c9bcf8e

+ 11 - 4
PULL_DATA_FACTORY/PULL_DATA.js

@@ -77,7 +77,7 @@ async function processTask(timeRange){
                         video_id:element.awemeId,
                         materialId:element.materialId,
                         video_link:element.awemeUrl,
-                        title:element.title,
+                        title:CMD.subTitle(element.title),
                         publish_time:new Date(element.publishTime),
                         kepp_num:info.kepp_num,
                         comment_num:info.comment_num,
@@ -103,6 +103,12 @@ async function processTask(timeRange){
     }
 
 }
+CMD.subTitle = function(title){
+    if(title.length>299){
+        return title.substring(0, 299);
+    }
+    return title
+}
 CMD.isRight = function(FilterConfig,origin_element){
     if(origin_element.likeCount.count < FilterConfig.like_num){// console.log("点赞数正确")
         return false
@@ -209,7 +215,8 @@ CMD.init = async function(){
             if(result.success){
 
             }else{
-                cur_day_data[today] =  await manager.getRecord(today);
+                let record_res =  await manager.getRecord(today);
+                cur_day_data[today]  = record_res.content
             }
             cur_page = 0
             // 示例:实际任务逻辑
@@ -377,14 +384,14 @@ CMD.init = async function(){
         },
         {
           name: '下午区间',
-          start: '16:43',
+          start: '16:00',
           timestamp: 1733817600000,
           hour: 16,
           timeFormat: '12/10/2024, 4:00:00 PM'
         },
         {
           name: '下午区间',
-          start: '17:00',
+          start: '17:08',
           timestamp: 1733821200000,
           hour: 17,
           timeFormat: '12/10/2024, 5:00:00 PM'

+ 21 - 5
PULL_DATA_FACTORY/daily_records.js

@@ -52,7 +52,6 @@ class DailyRecordManager {
         }
     }
 
-    // 获取记录
     async getRecord(date) {
         try {
             const connection = await this.pool.getConnection();
@@ -62,10 +61,27 @@ class DailyRecordManager {
                     [date]
                 );
                 
-                return rows.length > 0 ? {
-                    ...rows[0],
-                    content: JSON.parse(rows[0].content)
-                } : null;
+                if (rows.length === 0) {
+                    return null;
+                }
+    
+                // 添加内容检查
+                const record = rows[0];
+                let parsedContent = {};
+                
+                if (record.content) {
+                    try {
+                        parsedContent = JSON.parse(record.content);
+                    } catch (jsonError) {
+                        console.warn('JSON解析失败,使用默认空对象:', jsonError);
+                    }
+                }
+    
+                return {
+                    ...record,
+                    content: parsedContent
+                };
+                
             } finally {
                 connection.release();
             }