mirror of
https://github.com/rachelos/we-mp-rss.git
synced 2026-08-30 18:01:55 +08:00
1.4.9-Fix
This commit is contained in:
@@ -199,3 +199,4 @@ The following are the environment variable configurations supported in `config.y
|
||||
| `EXPORT_PDF` | `False` | Whether to enable PDF export functionality |
|
||||
|
||||
|
||||
|
||||
|
||||
+2
-3
@@ -120,9 +120,8 @@ class Db:
|
||||
art.content=art.content
|
||||
|
||||
if art.content_html is None:
|
||||
from tools.html import htmltools
|
||||
from driver.wxarticle import Web
|
||||
art.content_html = Web.clean_article_content(art.content)
|
||||
from tools.fix import fix_html
|
||||
art.content_html = fix_html(art.content)
|
||||
from core.models.base import DATA_STATUS
|
||||
art.status=DATA_STATUS.ACTIVE
|
||||
session.add(art)
|
||||
|
||||
@@ -11,10 +11,10 @@ class ArticleBase(Base):
|
||||
url=Column(String(500))
|
||||
description=Column(Text)
|
||||
status = Column(Integer,default=1)
|
||||
publish_time = Column(BigInteger,index=True)
|
||||
publish_time = Column(Integer,index=True)
|
||||
created_at = Column(DateTime)
|
||||
updated_at = Column(BigInteger)
|
||||
updated_at_millis = Column(BigInteger)
|
||||
updated_at_millis = Column(BigInteger,index=True)
|
||||
is_export = Column(Integer)
|
||||
is_read = Column(Integer, default=0)
|
||||
class Article(ArticleBase):
|
||||
|
||||
+2
-2
@@ -62,13 +62,13 @@ class WXArticleFetcher:
|
||||
dt = dt.replace(year=current_year - 1)
|
||||
else:
|
||||
dt = datetime.strptime(publish_time_str, fmt)
|
||||
return int(dt.timestamp() * 1000)
|
||||
return int(dt.timestamp())
|
||||
except ValueError:
|
||||
continue
|
||||
|
||||
# 如果所有格式都失败,返回当前时间戳
|
||||
print_warning(f"无法解析时间格式: {publish_time_str},使用当前时间")
|
||||
return int(datetime.now().timestamp() * 1000)
|
||||
return int(datetime.now().timestamp())
|
||||
|
||||
except Exception as e:
|
||||
print_error(f"时间转换失败: {e}")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from core.models.article import Article,DATA_STATUS
|
||||
import core.db as db
|
||||
from tools.fix import fix_html
|
||||
from core.wait import Wait
|
||||
from core.wx.base import WxGather
|
||||
from time import sleep
|
||||
@@ -39,7 +40,7 @@ def fetch_articles_without_content():
|
||||
if content:
|
||||
# 更新内容
|
||||
article.content = content
|
||||
article.content_html = Web.clean_article_content(content)
|
||||
article.content_html =fix_html(content)
|
||||
if content=="DELETED":
|
||||
print_error(f"获取文章 {article.title} 内容已被发布者删除")
|
||||
article.status = DATA_STATUS.DELETED
|
||||
|
||||
@@ -40,7 +40,7 @@ if __name__ == '__main__':
|
||||
from jobs.cascade_task_dispatcher import cascade_schedule_service
|
||||
cascade_schedule_service.start()
|
||||
|
||||
if cfg.args.job =="True" and cfg.get("server.enable_job",False) and cascade_service_started:
|
||||
if cfg.args.job =="True" and cfg.get("server.enable_job",False):
|
||||
from jobs import start_all_task
|
||||
threading.Thread(target=start_all_task,daemon=False).start()
|
||||
else:
|
||||
|
||||
+4
-6
@@ -101,10 +101,8 @@ def test_Gather_Article():
|
||||
]
|
||||
for url in urls:
|
||||
content= ga.content_extract(url)
|
||||
print(content)
|
||||
|
||||
|
||||
|
||||
content1 = Web.clean_article_content(content)
|
||||
print(len(content),len(content1))
|
||||
def test_screenshot():
|
||||
from playwright.sync_api import sync_playwright,TimeoutError
|
||||
playwright=sync_playwright().start()
|
||||
@@ -183,11 +181,11 @@ if __name__=="__main__":
|
||||
# asyncio.run(test_Article())
|
||||
# test_Gather_Article()
|
||||
# testWx_Api()
|
||||
# test_fetch_articles_without_content()
|
||||
test_fetch_articles_without_content()
|
||||
# testWeb()
|
||||
# testNotice()
|
||||
# testMd2Doc()
|
||||
testLogin()
|
||||
# testLogin()
|
||||
# test_feed_and_articles_template()
|
||||
# testJob()
|
||||
# test_send_wx_code()
|
||||
|
||||
@@ -8,6 +8,8 @@ from markdown.extensions import codehilite, tables, toc, fenced_code
|
||||
from bs4 import BeautifulSoup
|
||||
import re
|
||||
from typing import Dict, List, Optional, Any
|
||||
|
||||
from pyee.cls import on
|
||||
from core.print import print_info, print_error, print_warning
|
||||
|
||||
|
||||
@@ -43,6 +45,7 @@ class MarkdownToHtmlConverter:
|
||||
]
|
||||
|
||||
# 设置默认配置
|
||||
self.only_body = self.config.get('only_body', True)
|
||||
self.extensions = self.config.get('extensions', self.default_extensions)
|
||||
self.remove_images = self.config.get('remove_images', False)
|
||||
self.remove_links = self.config.get('remove_links', False)
|
||||
@@ -119,7 +122,7 @@ class MarkdownToHtmlConverter:
|
||||
|
||||
html_content = md.convert(markdown_content)
|
||||
html_content = self._post_process_html(html_content)
|
||||
html_content = self._wrap_html(html_content)
|
||||
html_content = self._wrap_html(html_content,only_body=self.only_body)
|
||||
|
||||
# 提取元数据
|
||||
metadata = {
|
||||
@@ -246,7 +249,7 @@ class MarkdownToHtmlConverter:
|
||||
if not img.get('loading'):
|
||||
img['loading'] = 'lazy'
|
||||
|
||||
def _wrap_html(self, html_content: str) -> str:
|
||||
def _wrap_html(self, html_content: str,only_body:bool=True) -> str:
|
||||
"""
|
||||
包装 HTML 内容,添加完整的 HTML 结构
|
||||
|
||||
@@ -256,6 +259,8 @@ class MarkdownToHtmlConverter:
|
||||
Returns:
|
||||
完整的 HTML 文档
|
||||
"""
|
||||
if only_body:
|
||||
return html_content
|
||||
css_styles = self._get_default_css()
|
||||
if self.custom_css:
|
||||
css_styles += '\n' + self.custom_css
|
||||
|
||||
Reference in New Issue
Block a user