Przeglądaj źródła

fix: 过滤 platforms.sources 中 enabled: false 的数据源,修复全局开关失效,升级至 v6.6.2/mcp-v4.0.4

sansan 2 tygodni temu
rodzic
commit
b109701b42

+ 1 - 1
README-EN.md

@@ -11,7 +11,7 @@ Deploy in <strong>30 seconds</strong> — Say goodbye to endless scrolling, only
 [![GitHub Stars](https://img.shields.io/github/stars/sansan0/TrendRadar?style=flat-square&logo=github&color=yellow)](https://github.com/sansan0/TrendRadar/stargazers)
 [![GitHub Forks](https://img.shields.io/github/forks/sansan0/TrendRadar?style=flat-square&logo=github&color=blue)](https://github.com/sansan0/TrendRadar/network/members)
 [![License](https://img.shields.io/badge/license-GPL--3.0-blue.svg?style=flat-square)](LICENSE)
-[![Version](https://img.shields.io/badge/version-v6.6.1-blue.svg)](https://github.com/sansan0/TrendRadar)
+[![Version](https://img.shields.io/badge/version-v6.6.2-blue.svg)](https://github.com/sansan0/TrendRadar)
 [![MCP](https://img.shields.io/badge/MCP-v4.0.2-green.svg)](https://github.com/sansan0/TrendRadar)
 [![RSS](https://img.shields.io/badge/RSS-Feed_Support-orange.svg?style=flat-square&logo=rss&logoColor=white)](https://github.com/sansan0/TrendRadar)
 [![AI Translation](https://img.shields.io/badge/AI-Multi--Language-purple.svg?style=flat-square)](https://github.com/sansan0/TrendRadar)

+ 1 - 1
README.md

@@ -12,7 +12,7 @@
 [![GitHub Stars](https://img.shields.io/github/stars/sansan0/TrendRadar?style=flat-square&logo=github&color=yellow)](https://github.com/sansan0/TrendRadar/stargazers)
 [![GitHub Forks](https://img.shields.io/github/forks/sansan0/TrendRadar?style=flat-square&logo=github&color=blue)](https://github.com/sansan0/TrendRadar/network/members)
 [![License](https://img.shields.io/badge/license-GPL--3.0-blue.svg?style=flat-square)](LICENSE)
-[![Version](https://img.shields.io/badge/version-v6.6.1-blue.svg)](https://github.com/sansan0/TrendRadar)
+[![Version](https://img.shields.io/badge/version-v6.6.2-blue.svg)](https://github.com/sansan0/TrendRadar)
 [![MCP](https://img.shields.io/badge/MCP-v4.0.2-green.svg)](https://github.com/sansan0/TrendRadar)
 [![RSS](https://img.shields.io/badge/RSS-订阅源支持-orange.svg?style=flat-square&logo=rss&logoColor=white)](https://github.com/sansan0/TrendRadar)
 [![AI翻译](https://img.shields.io/badge/AI-多语言推送-purple.svg?style=flat-square)](https://github.com/sansan0/TrendRadar)

+ 1 - 1
mcp_server/__init__.py

@@ -5,4 +5,4 @@ TrendRadar MCP Server
 
 """
 
-__version__ = "4.0.3"
+__version__ = "4.0.4"

+ 1 - 1
mcp_server/services/data_service.py

@@ -487,7 +487,7 @@ class DataService:
                 "use_proxy": advanced_crawler.get("use_proxy", False),
                 "request_interval": advanced_crawler.get("request_interval", 1),
                 "retry_times": 3,
-                "platforms": [p["id"] for p in platforms_config.get("sources", [])]
+                "platforms": [p["id"] for p in platforms_config.get("sources", []) if p.get("enabled", True)]
             }
 
         if section == "all" or section == "push":

+ 1 - 1
mcp_server/tools/system.py

@@ -88,7 +88,7 @@ class SystemManagementTools:
                 "热榜平台已禁用",
                 suggestion="请检查 config/config.yaml 中的 platforms.enabled 配置"
             )
-        all_platforms = platforms_config.get("sources", [])
+        all_platforms = [p for p in platforms_config.get("sources", []) if p.get("enabled", True)]
         if not all_platforms:
             raise CrawlTaskError(
                 "配置文件中没有平台配置",

+ 1 - 1
mcp_server/utils/validators.py

@@ -185,7 +185,7 @@ def get_supported_platforms() -> List[str]:
             config = yaml.safe_load(f)
             platforms_config = config.get('platforms', {})
             sources = platforms_config.get('sources', [])
-            _platforms_cache = [p['id'] for p in sources if 'id' in p]
+            _platforms_cache = [p['id'] for p in sources if 'id' in p and p.get('enabled', True)]
             _platforms_config_mtime = current_mtime
             return _platforms_cache
     except Exception as e:

+ 1 - 1
pyproject.toml

@@ -1,6 +1,6 @@
 [project]
 name = "trendradar"
-version = "6.6.1"
+version = "6.6.2"
 description = "TrendRadar - 热点新闻聚合与分析工具"
 requires-python = ">=3.12"
 dependencies = [

+ 1 - 1
trendradar/__init__.py

@@ -9,5 +9,5 @@ TrendRadar - 热点新闻聚合与分析工具
 
 from trendradar.context import AppContext
 
-__version__ = "6.6.1"
+__version__ = "6.6.2"
 __all__ = ["AppContext", "__version__"]

+ 6 - 4
trendradar/__main__.py

@@ -1028,14 +1028,14 @@ class NewsAnalyzer:
 
         return False
 
-    def _initialize_and_check_config(self) -> None:
-        """通用初始化和配置检查"""
+    def _initialize_and_check_config(self) -> bool:
+        """通用初始化和配置检查。返回 True 表示可以继续执行。"""
         now = self.ctx.get_time()
         print(f"当前北京时间: {now.strftime('%Y-%m-%d %H:%M:%S')}")
 
         if not self.ctx.config["ENABLE_CRAWLER"]:
             print("爬虫功能已禁用(ENABLE_CRAWLER=False),程序退出")
-            return
+            return False
 
         has_notification = self._has_notification_configured()
         if not self.ctx.config["ENABLE_NOTIFICATION"]:
@@ -1048,6 +1048,7 @@ class NewsAnalyzer:
         mode_strategy = self._get_mode_strategy()
         print(f"报告模式: {self.report_mode}")
         print(f"运行模式: {mode_strategy['description']}")
+        return True
 
     def _crawl_data(self) -> Tuple[Dict, Dict, List]:
         """执行数据爬取"""
@@ -1706,7 +1707,8 @@ class NewsAnalyzer:
     def run(self) -> None:
         """执行分析流程"""
         try:
-            self._initialize_and_check_config()
+            if not self._initialize_and_check_config():
+                return
 
             mode_strategy = self._get_mode_strategy()
 

+ 1 - 1
trendradar/core/loader.py

@@ -576,7 +576,7 @@ def load_config(config_path: Optional[str] = None) -> Dict[str, Any]:
 
     # 平台配置
     platforms_config = config_data.get("platforms", {})
-    config["PLATFORMS"] = platforms_config.get("sources", [])
+    config["PLATFORMS"] = [p for p in platforms_config.get("sources", []) if p.get("enabled", True)]
 
     # RSS 配置
     config["RSS"] = _load_rss_config(config_data)

+ 1 - 1
uv.lock

@@ -1996,7 +1996,7 @@ wheels = [
 
 [[package]]
 name = "trendradar"
-version = "6.6.1"
+version = "6.6.2"
 source = { editable = "." }
 dependencies = [
     { name = "boto3" },

+ 1 - 1
version

@@ -1 +1 @@
-6.6.1
+6.6.2

+ 1 - 1
version_mcp

@@ -1 +1 @@
-4.0.3
+4.0.4