diff --git a/core/db.py b/core/db.py index cd152eb6..17680a99 100644 --- a/core/db.py +++ b/core/db.py @@ -123,10 +123,13 @@ class Db: art.id=f"{str(art.mp_id)}-{art.id}".replace("MP_WXS_","") # type: ignore if check_exist: # 检查文章是否已存在 - existing_article = session.query(Article.id).filter( + existing_article = session.query(Article.id,Article.publish_time,Article.status).filter( (Article.url == art.url) | (Article.id == art.id) ).first() if existing_article is not None: + # 当更新时间和状态都相同时,不需要更新 + if art.publish_time == existing_article.publish_time and art.status == existing_article.status: # type: ignore + return False if art.content_html:# type: ignore from tools.fix import fix_html art.content_html = fix_html(art.content_html) # type: ignore diff --git a/jobs/article.py b/jobs/article.py index 5b908ed8..64dd1340 100644 --- a/jobs/article.py +++ b/jobs/article.py @@ -6,7 +6,7 @@ from core.models.article import Article DB=db.Db(tag="文章采集API") -def UpdateArticle(art:dict,check_exist=False): +def UpdateArticle(art:dict,check_exist=True): mps_count=0 if DEBUG: # DB.delete_article(art)