mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-06 16:07:01 +08:00
Merge pull request #3187 from InfinityPacer/feature/scheduler
This commit is contained in:
@@ -8,6 +8,7 @@ from app import schemas
|
|||||||
from app.chain.site import SiteChain
|
from app.chain.site import SiteChain
|
||||||
from app.chain.torrents import TorrentsChain
|
from app.chain.torrents import TorrentsChain
|
||||||
from app.core.event import EventManager
|
from app.core.event import EventManager
|
||||||
|
from app.core.plugin import PluginManager
|
||||||
from app.core.security import verify_token
|
from app.core.security import verify_token
|
||||||
from app.db import get_db
|
from app.db import get_db
|
||||||
from app.db.models import User
|
from app.db.models import User
|
||||||
@@ -351,6 +352,8 @@ def auth_site(
|
|||||||
return schemas.Response(success=False, message="请输入认证站点和认证参数")
|
return schemas.Response(success=False, message="请输入认证站点和认证参数")
|
||||||
status, msg = SitesHelper().check_user(auth_info.site, auth_info.params)
|
status, msg = SitesHelper().check_user(auth_info.site, auth_info.params)
|
||||||
SystemConfigOper().set(SystemConfigKey.UserSiteAuthParams, auth_info.dict())
|
SystemConfigOper().set(SystemConfigKey.UserSiteAuthParams, auth_info.dict())
|
||||||
|
PluginManager().init_config()
|
||||||
|
Scheduler().init_plugin_jobs()
|
||||||
return schemas.Response(success=status, message=msg)
|
return schemas.Response(success=status, message=msg)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-7
@@ -82,10 +82,6 @@ class Scheduler(metaclass=Singleton):
|
|||||||
else:
|
else:
|
||||||
status, msg = SitesHelper().check_user()
|
status, msg = SitesHelper().check_user()
|
||||||
if status:
|
if status:
|
||||||
# 仅重试时,才需要初始化插件服务
|
|
||||||
if self._auth_count > 0:
|
|
||||||
PluginManager().init_config()
|
|
||||||
self.init_plugin_jobs()
|
|
||||||
self._auth_count = 0
|
self._auth_count = 0
|
||||||
logger.info(f"{msg} 用户认证成功")
|
logger.info(f"{msg} 用户认证成功")
|
||||||
SchedulerChain().post_message(
|
SchedulerChain().post_message(
|
||||||
@@ -96,6 +92,9 @@ class Scheduler(metaclass=Singleton):
|
|||||||
link=settings.MP_DOMAIN('#/site')
|
link=settings.MP_DOMAIN('#/site')
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
PluginManager().init_config()
|
||||||
|
self.init_plugin_jobs()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self._auth_count += 1
|
self._auth_count += 1
|
||||||
logger.error(f"用户认证失败:{msg},共失败 {self._auth_count} 次")
|
logger.error(f"用户认证失败:{msg},共失败 {self._auth_count} 次")
|
||||||
@@ -175,9 +174,6 @@ class Scheduler(metaclass=Singleton):
|
|||||||
# 停止定时服务
|
# 停止定时服务
|
||||||
self.stop()
|
self.stop()
|
||||||
|
|
||||||
# 用户认证立即执行一次
|
|
||||||
user_auth()
|
|
||||||
|
|
||||||
# 调试模式不启动定时服务
|
# 调试模式不启动定时服务
|
||||||
if settings.DEV:
|
if settings.DEV:
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ from app.helper.message import MessageHelper
|
|||||||
from app.scheduler import Scheduler
|
from app.scheduler import Scheduler
|
||||||
from app.monitor import Monitor
|
from app.monitor import Monitor
|
||||||
from app.schemas import Notification, NotificationType
|
from app.schemas import Notification, NotificationType
|
||||||
|
from app.schemas.types import SystemConfigKey
|
||||||
from app.db import close_database
|
from app.db import close_database
|
||||||
|
from app.db.systemconfig_oper import SystemConfigOper
|
||||||
from app.chain.command import CommandChain
|
from app.chain.command import CommandChain
|
||||||
|
|
||||||
|
|
||||||
@@ -72,6 +74,19 @@ def clear_temp():
|
|||||||
SystemUtils.clear(settings.CACHE_PATH / "images", days=7)
|
SystemUtils.clear(settings.CACHE_PATH / "images", days=7)
|
||||||
|
|
||||||
|
|
||||||
|
def user_auth():
|
||||||
|
"""
|
||||||
|
用户认证检查
|
||||||
|
"""
|
||||||
|
if SitesHelper().auth_level >= 2:
|
||||||
|
return
|
||||||
|
auth_conf = SystemConfigOper().get(SystemConfigKey.UserSiteAuthParams)
|
||||||
|
if auth_conf:
|
||||||
|
SitesHelper().check_user(**auth_conf)
|
||||||
|
else:
|
||||||
|
SitesHelper().check_user()
|
||||||
|
|
||||||
|
|
||||||
def check_auth():
|
def check_auth():
|
||||||
"""
|
"""
|
||||||
检查认证状态
|
检查认证状态
|
||||||
@@ -128,6 +143,8 @@ def start_modules(_: FastAPI):
|
|||||||
SitesHelper()
|
SitesHelper()
|
||||||
# 资源包检测
|
# 资源包检测
|
||||||
ResourceHelper()
|
ResourceHelper()
|
||||||
|
# 用户认证
|
||||||
|
user_auth()
|
||||||
# 加载模块
|
# 加载模块
|
||||||
ModuleManager()
|
ModuleManager()
|
||||||
# 启动事件消费
|
# 启动事件消费
|
||||||
|
|||||||
Reference in New Issue
Block a user