瀏覽代碼

checkVideoStatusDaily.py 删除关闭代码
注释运行日志

罗俊辉 7 月之前
父節點
當前提交
af8a363428
共有 4 個文件被更改,包括 34 次插入26 次删除
  1. 1 1
      applications/wxSpiderApi.py
  2. 0 8
      checkVideoStatusDaily.py
  3. 5 5
      getOffVideosDaily.py
  4. 28 12
      updateAccountV3.py

+ 1 - 1
applications/wxSpiderApi.py

@@ -35,7 +35,7 @@ class WeixinSpider(object):
         return response.json()
 
     @classmethod
-    @retryOnNone()
+    # @retryOnNone()
     def get_article_text(cls, content_link):
         """
         获取文章

+ 0 - 8
checkVideoStatusDaily.py

@@ -102,14 +102,6 @@ class VideoStatusManager(object):
         print("total", len(video_id_list))
         print("bad_total", bad_count)
 
-    # @classmethod
-    # def closeConnection(cls):
-    #     """
-    #     关闭连接
-    #     :return:
-    #     """
-    #     cls.db_client.close()
-
 
 if __name__ == '__main__':
     while True:

+ 5 - 5
getOffVideosDaily.py

@@ -241,8 +241,8 @@ if __name__ == '__main__':
     while True:
         schedule.run_pending()
         time.sleep(1)
-        log(
-            task="getOffVideos",
-            function="main",
-            message="自动下架视频任务正常执行"
-        )
+        # log(
+        #     task="getOffVideos",
+        #     function="main",
+        #     message="自动下架视频任务正常执行"
+        # )

+ 28 - 12
updateAccountV3.py

@@ -5,7 +5,7 @@ import json
 import time
 import schedule
 from tqdm import tqdm
-from datetime import datetime
+from datetime import datetime, timedelta
 
 from applications import longArticlesMySQL, PQMySQL, DeNetMysql, Functions
 
@@ -39,7 +39,7 @@ class UpdateAccountInfoVersion3(object):
                 D[account_name][dt] = fans
             else:
                 D[account_name] = {dt: fans}
-        print(json.dumps(D, ensure_ascii=False, indent=4))
+        # print(json.dumps(D, ensure_ascii=False, indent=4))
         return D
 
     @classmethod
@@ -72,7 +72,7 @@ class UpdateAccountInfoVersion3(object):
             temp[4] = fans_dict.get(temp[3], {}).get(dt, 0)
             temp[-1] = rate_dict.get(temp[3], {}).get(temp[1], 0)
             temp[5] = fans_dict.get(temp[3], {}).get(dt, 0) * rate_dict.get(temp[3], {}).get(temp[1], 0)
-            print(temp)
+            temp[7] = 1
             usql = f"""
             INSERT INTO account_avg_info_v3
             (gh_id, position, update_time, account_name, fans, read_avg, like_avg, status, account_type, account_mode, account_source, account_status, business_type, read_rate_avg)
@@ -105,6 +105,19 @@ class UpdateAccountInfoVersion3(object):
                 except Exception as e:
                     print(e)
 
+            # 修改前一天的状态为 0
+            uuu_sql = f"""
+            UPDATE account_avg_info_v3
+            SET status = %s
+            where update_time != %s and account_name = %s and position = %s;
+            """
+            cls.pq.update(
+                sql=uuu_sql,
+                params=(
+                    0, dt, temp[3], temp[1]
+                )
+            )
+
 
 def updateDaily():
     """
@@ -114,18 +127,21 @@ def updateDaily():
     Up = UpdateAccountInfoVersion3()
     fd = Up.getAccountFans()
     rd = Up.getAccountRate()
-    today_dt = datetime.today().__str__().split(" ")[0]
-    # today_dt = '2024-09-12'
-    Up.reverseSingleDay(today_dt, fd, rd)
+    dt_object = datetime.fromtimestamp(int(time.time()))
+    one_day = timedelta(days=1)
+    yesterday = dt_object - one_day
+    yesterday_str = yesterday.strftime('%Y-%m-%d')
+    # print(yesterday_str)
+    Up.reverseSingleDay(yesterday_str, fd, rd)
     Up.lam.close()
     Up.pq.close()
     Up.de.close()
 
 
-# if __name__ == '__main__':
+if __name__ == '__main__':
+    # updateDaily()
+    schedule.every().day.at("10:15").do(Functions().job_with_thread, updateDaily)
 
-    # schedule.every().day.at("10:15").do(Functions().job_with_thread, updateDaily)
-    #
-    # while True:
-    #     schedule.run_pending()
-    #     time.sleep(1)
+    while True:
+        schedule.run_pending()
+        time.sleep(1)