From 90d5a8b0c938b383a0fb0b9412745e51c2176edf Mon Sep 17 00:00:00 2001 From: jxxghp Date: Mon, 6 May 2024 11:54:32 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=95=B0=E6=8D=AE=E5=85=B1=E4=BA=AB?= =?UTF-8?q?=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 ++++---- app/core/config.py | 4 ++++ app/helper/plugin.py | 11 ++++++++--- app/helper/subscribe.py | 12 +++++++++--- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 1f13917b..500849ec 100644 --- a/README.md +++ b/README.md @@ -127,13 +127,13 @@ MoviePilot需要配套下载器和媒体服务器配合使用。 - **SCRAP_FOLLOW_TMDB:** 新增已入库媒体是否跟随TMDB信息变化,`true`/`false`,默认`true`,为`false`时即使TMDB信息变化了也会仍然按历史记录中已入库的信息进行刮削 --- - **AUTO_DOWNLOAD_USER:** 远程交互搜索时自动择优下载的用户ID(消息通知渠道的用户ID),多个用户使用,分割,设置为 all 代表全部用户自动择优下载,未设置需要手动选择资源或者回复`0`才自动择优下载 +- **DOWNLOAD_SUBTITLE:** 下载站点字幕,`true`/`false`,默认`true` +- **SEARCH_MULTIPLE_NAME:** 搜索时是否使用多个名称搜索,`true`/`false`,默认`false`,开启后会使用多个名称进行搜索,搜索结果会更全面,但会增加搜索时间;关闭时只要其中一个名称搜索到结果或全部名称搜索完毕即停止 +- **SUBSCRIBE_STATISTIC_SHARE:** 是否匿名分享订阅数据,用于统计和展示用户热门订阅,`true`/`false`,默认`true` +- **PLUGIN_STATISTIC_SHARE:** 是否匿名分享插件安装统计数据,用于统计和显示插件下载安装次数,`true`/`false`,默认`true` --- - **OCR_HOST:** OCR识别服务器地址,格式:`http(s)://ip:port`,用于识别站点验证码实现自动登录获取Cookie等,不配置默认使用内建服务器`https://movie-pilot.org`,可使用 [这个镜像](https://hub.docker.com/r/jxxghp/moviepilot-ocr) 自行搭建。 --- -- **DOWNLOAD_SUBTITLE:** 下载站点字幕,`true`/`false`,默认`true` ---- -- **SEARCH_MULTIPLE_NAME:** 搜索时是否使用多个名称搜索,`true`/`false`,默认`false`,开启后会使用多个名称进行搜索,搜索结果会更全面,但会增加搜索时间;关闭时只要其中一个名称搜索到结果或全部名称搜索完毕即停止 ---- - **MOVIE_RENAME_FORMAT:** 电影重命名格式,基于jinjia2语法 `MOVIE_RENAME_FORMAT`支持的配置项: diff --git a/app/core/config.py b/app/core/config.py index 172adc64..15fc99f5 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -242,6 +242,10 @@ class Settings(BaseSettings): DOH_ENABLE: bool = True # 搜索多个名称 SEARCH_MULTIPLE_NAME: bool = False + # 订阅数据共享 + SUBSCRIBE_STATISTIC_SHARE: bool = True + # 插件安装数据共享 + PLUGIN_STATISTIC_SHARE: bool = True @validator("SUBSCRIBE_RSS_INTERVAL", "COOKIECLOUD_INTERVAL", diff --git a/app/helper/plugin.py b/app/helper/plugin.py index 36fde201..12309418 100644 --- a/app/helper/plugin.py +++ b/app/helper/plugin.py @@ -30,9 +30,10 @@ class PluginHelper(metaclass=Singleton): def __init__(self): self.systemconfig = SystemConfigOper() - if not self.systemconfig.get(SystemConfigKey.PluginInstallReport): - if self.install_report(): - self.systemconfig.set(SystemConfigKey.PluginInstallReport, "1") + if settings.PLUGIN_STATISTIC_SHARE: + if not self.systemconfig.get(SystemConfigKey.PluginInstallReport): + if self.install_report(): + self.systemconfig.set(SystemConfigKey.PluginInstallReport, "1") @cached(cache=TTLCache(maxsize=1000, ttl=1800)) def get_plugins(self, repo_url: str) -> Dict[str, dict]: @@ -89,6 +90,8 @@ class PluginHelper(metaclass=Singleton): """ 安装插件统计 """ + if not settings.PLUGIN_STATISTIC_SHARE: + return False if not pid: return False res = RequestUtils(timeout=5).get_res(self._install_reg % pid) @@ -100,6 +103,8 @@ class PluginHelper(metaclass=Singleton): """ 上报存量插件安装统计 """ + if not settings.PLUGIN_STATISTIC_SHARE: + return False plugins = self.systemconfig.get(SystemConfigKey.UserInstalledPlugins) if not plugins: return False diff --git a/app/helper/subscribe.py b/app/helper/subscribe.py index df50ff8b..3c70ddb1 100644 --- a/app/helper/subscribe.py +++ b/app/helper/subscribe.py @@ -3,6 +3,7 @@ from typing import List from cachetools import TTLCache, cached +from app.core.config import settings from app.db.subscribe_oper import SubscribeOper from app.db.systemconfig_oper import SystemConfigOper from app.schemas.types import SystemConfigKey @@ -23,9 +24,10 @@ class SubscribeHelper(metaclass=Singleton): def __init__(self): self.systemconfig = SystemConfigOper() - if not self.systemconfig.get(SystemConfigKey.SubscribeReport): - if self.sub_report(): - self.systemconfig.set(SystemConfigKey.SubscribeReport, "1") + if settings.SUBSCRIBE_STATISTIC_SHARE: + if not self.systemconfig.get(SystemConfigKey.SubscribeReport): + if self.sub_report(): + self.systemconfig.set(SystemConfigKey.SubscribeReport, "1") @cached(cache=TTLCache(maxsize=10, ttl=1800)) def get_statistic(self, stype: str, page: int = 1, count: int = 30) -> List[dict]: @@ -45,6 +47,8 @@ class SubscribeHelper(metaclass=Singleton): """ 新增订阅统计 """ + if not settings.SUBSCRIBE_STATISTIC_SHARE: + return False res = RequestUtils(timeout=5, headers={ "Content-Type": "application/json" }).post_res(self._sub_reg, json=sub) @@ -64,6 +68,8 @@ class SubscribeHelper(metaclass=Singleton): """ 上报存量订阅统计 """ + if not settings.SUBSCRIBE_STATISTIC_SHARE: + return False subscribes = SubscribeOper().list() if not subscribes: return True