Selaa lähdekoodia

updatePublishedMsgDaily.py

luojunhui 6 kuukautta sitten
vanhempi
commit
95093ae427
1 muutettua tiedostoa jossa 12 lisäystä ja 2 poistoa
  1. 12 2
      updatePublishedMsgDaily.py

+ 12 - 2
updatePublishedMsgDaily.py

@@ -519,6 +519,10 @@ def update_publish_timestamp(db_client, row):
             json.dumps(root_source_id_list, ensure_ascii=False),
             wx_sn
         ))
+    if publish_timestamp_s == REQUEST_FAIL_STATUS:
+        return row
+    else:
+        return None
 
 
 def get_article_detail_job():
@@ -549,10 +553,12 @@ def get_article_detail_job():
             print(error_msg)
     # check 一遍存在请求失败-1 && 0 的文章
     process_failed_articles = get_articles(db_client)
+    fail_list = []
     if process_failed_articles:
         for article in tqdm(process_failed_articles):
             try:
-                update_publish_timestamp(db_client=db_client, row=article)
+                res = update_publish_timestamp(db_client=db_client, row=article)
+                fail_list.append({"wx_sn": res[1], "url": res[0]})
             except Exception as e:
                 print(e)
                 error_msg = traceback.format_exc()
@@ -575,7 +581,11 @@ def get_article_detail_job():
         sql=update_sql,
         params=(0, 0)
     )
-    print(affected_rows)
+    if fail_list:
+        bot(
+            title="更新文章任务,请求detail失败",
+            detail=fail_list
+        )
 
 
 def main():