Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
911651a5f7
@ -134,20 +134,37 @@ class AutoSignIn(_PluginBase):
|
|||||||
self._start_time = int(times[0])
|
self._start_time = int(times[0])
|
||||||
# 23
|
# 23
|
||||||
self._end_time = int(times[1])
|
self._end_time = int(times[1])
|
||||||
if self._start_time and self._end_time:
|
if self._start_time and self._end_time:
|
||||||
|
self._scheduler.add_job(func=self.sign_in,
|
||||||
|
trigger="interval",
|
||||||
|
hours=float(self._cron.strip()),
|
||||||
|
name=f"站点自动{self._action}")
|
||||||
|
logger.info(
|
||||||
|
f"站点自动{self._action}服务启动,执行周期 {self._start_time}点-{self._end_time}点 每{self._cron}小时执行一次")
|
||||||
|
else:
|
||||||
|
logger.error(f"站点自动{self._action}服务启动失败,周期格式错误")
|
||||||
|
# 推送实时消息
|
||||||
|
self.systemmessage.put(f"执行周期配置错误")
|
||||||
|
self._cron = ""
|
||||||
|
self._enabled = False
|
||||||
|
self.__update_config()
|
||||||
|
else:
|
||||||
|
# 默认0-24 按照周期运行
|
||||||
|
self._start_time = 0
|
||||||
|
self._end_time = 24
|
||||||
self._scheduler.add_job(func=self.sign_in,
|
self._scheduler.add_job(func=self.sign_in,
|
||||||
trigger="interval",
|
trigger="interval",
|
||||||
hours=float(self._cron.strip()),
|
hours=float(self._cron.strip()),
|
||||||
name=f"站点自动{self._action}")
|
name=f"站点自动{self._action}")
|
||||||
logger.info(f"站点自动{self._action}服务启动,执行周期 {self._cron} {self._start_time}-{self._end_time}")
|
logger.info(
|
||||||
else:
|
f"站点自动{self._action}服务启动,执行周期 {self._start_time}点-{self._end_time}点 每{self._cron}小时执行一次")
|
||||||
logger.error(f"站点自动{self._action}服务启动失败,周期格式错误")
|
|
||||||
# 推送实时消息
|
|
||||||
self.systemmessage.put(f"执行周期配置错误")
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.error(f"定时任务配置错误:{err}")
|
logger.error(f"定时任务配置错误:{err}")
|
||||||
# 推送实时消息
|
# 推送实时消息
|
||||||
self.systemmessage.put(f"执行周期配置错误:{err}")
|
self.systemmessage.put(f"执行周期配置错误:{err}")
|
||||||
|
self._cron = ""
|
||||||
|
self._enabled = False
|
||||||
|
self.__update_config()
|
||||||
else:
|
else:
|
||||||
# 随机时间
|
# 随机时间
|
||||||
triggers = TimerUtils.random_scheduler(num_executions=2,
|
triggers = TimerUtils.random_scheduler(num_executions=2,
|
||||||
|
@ -69,7 +69,23 @@ class NAStoolSync(_PluginBase):
|
|||||||
self.tr = Transmission()
|
self.tr = Transmission()
|
||||||
|
|
||||||
# 读取sqlite数据
|
# 读取sqlite数据
|
||||||
gradedb = sqlite3.connect(self._nt_db_path)
|
try:
|
||||||
|
gradedb = sqlite3.connect(self._nt_db_path)
|
||||||
|
except Exception as e:
|
||||||
|
self.update_config(
|
||||||
|
{
|
||||||
|
"transfer": False,
|
||||||
|
"clear": False,
|
||||||
|
"nt_db_path": None,
|
||||||
|
"path": self._path,
|
||||||
|
"downloader": self._downloader,
|
||||||
|
"site": self._site,
|
||||||
|
"supp": self._supp,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
logger.error(f"无法打开数据库文件 {self._nt_db_path},请检查路径是否正确:{e}")
|
||||||
|
return
|
||||||
|
|
||||||
# 创建游标cursor来执行executeSQL语句
|
# 创建游标cursor来执行executeSQL语句
|
||||||
cursor = gradedb.cursor()
|
cursor = gradedb.cursor()
|
||||||
|
|
||||||
@ -520,180 +536,180 @@ class NAStoolSync(_PluginBase):
|
|||||||
拼装插件配置页面,需要返回两块数据:1、页面配置;2、数据结构
|
拼装插件配置页面,需要返回两块数据:1、页面配置;2、数据结构
|
||||||
"""
|
"""
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
'component': 'VForm',
|
'component': 'VForm',
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VRow',
|
'component': 'VRow',
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VCol',
|
'component': 'VCol',
|
||||||
'props': {
|
'props': {
|
||||||
'cols': 12,
|
'cols': 12,
|
||||||
'md': 4
|
'md': 4
|
||||||
},
|
},
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VSwitch',
|
'component': 'VSwitch',
|
||||||
'props': {
|
'props': {
|
||||||
'model': 'transfer',
|
'model': 'transfer',
|
||||||
'label': '同步记录'
|
'label': '同步记录'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'component': 'VCol',
|
'component': 'VCol',
|
||||||
'props': {
|
'props': {
|
||||||
'cols': 12,
|
'cols': 12,
|
||||||
'md': 4
|
'md': 4
|
||||||
},
|
},
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VSwitch',
|
'component': 'VSwitch',
|
||||||
'props': {
|
'props': {
|
||||||
'model': 'clear',
|
'model': 'clear',
|
||||||
'label': '清空记录'
|
'label': '清空记录'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'component': 'VCol',
|
'component': 'VCol',
|
||||||
'props': {
|
'props': {
|
||||||
'cols': 12,
|
'cols': 12,
|
||||||
'md': 4
|
'md': 4
|
||||||
},
|
},
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VSwitch',
|
'component': 'VSwitch',
|
||||||
'props': {
|
'props': {
|
||||||
'model': 'supp',
|
'model': 'supp',
|
||||||
'label': '补充数据'
|
'label': '补充数据'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'component': 'VRow',
|
'component': 'VRow',
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VCol',
|
'component': 'VCol',
|
||||||
'props': {
|
'props': {
|
||||||
'cols': 12,
|
'cols': 12,
|
||||||
},
|
},
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VTextField',
|
'component': 'VTextField',
|
||||||
'props': {
|
'props': {
|
||||||
'model': 'nt_db_path',
|
'model': 'nt_db_path',
|
||||||
'label': 'NAStool数据库user.db路径',
|
'label': 'NAStool数据库user.db路径',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'component': 'VRow',
|
'component': 'VRow',
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VCol',
|
'component': 'VCol',
|
||||||
'props': {
|
'props': {
|
||||||
'cols': 12,
|
'cols': 12,
|
||||||
},
|
},
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VTextarea',
|
'component': 'VTextarea',
|
||||||
'props': {
|
'props': {
|
||||||
'model': 'path',
|
'model': 'path',
|
||||||
'rows': '2',
|
'rows': '2',
|
||||||
'label': '历史记录路径映射',
|
'label': '历史记录路径映射',
|
||||||
'placeholder': 'NAStool路径:MoviePilot路径(一行一个)'
|
'placeholder': 'NAStool路径:MoviePilot路径(一行一个)'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'component': 'VRow',
|
'component': 'VRow',
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VCol',
|
'component': 'VCol',
|
||||||
'props': {
|
'props': {
|
||||||
'cols': 12,
|
'cols': 12,
|
||||||
},
|
},
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VTextarea',
|
'component': 'VTextarea',
|
||||||
'props': {
|
'props': {
|
||||||
'model': 'downloader',
|
'model': 'downloader',
|
||||||
'rows': '2',
|
'rows': '2',
|
||||||
'label': '插件数据下载器映射',
|
'label': '插件数据下载器映射',
|
||||||
'placeholder': 'NAStool下载器id:qbittorrent|transmission(一行一个)'
|
'placeholder': 'NAStool下载器id:qbittorrent|transmission(一行一个)'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'component': 'VRow',
|
'component': 'VRow',
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VCol',
|
'component': 'VCol',
|
||||||
'props': {
|
'props': {
|
||||||
'cols': 12,
|
'cols': 12,
|
||||||
},
|
},
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VTextarea',
|
'component': 'VTextarea',
|
||||||
'props': {
|
'props': {
|
||||||
'model': 'site',
|
'model': 'site',
|
||||||
'label': '下载历史站点映射',
|
'label': '下载历史站点映射',
|
||||||
'placeholder': 'NAStool站点名:MoviePilot站点名(一行一个)'
|
'placeholder': 'NAStool站点名:MoviePilot站点名(一行一个)'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'component': 'VRow',
|
'component': 'VRow',
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VCol',
|
'component': 'VCol',
|
||||||
'props': {
|
'props': {
|
||||||
'cols': 12,
|
'cols': 12,
|
||||||
},
|
},
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
'component': 'VAlert',
|
'component': 'VAlert',
|
||||||
'props': {
|
'props': {
|
||||||
'text': '开启清空记录时,会在导入历史数据之前删除MoviePilot之前的记录。'
|
'text': '开启清空记录时,会在导入历史数据之前删除MoviePilot之前的记录。'
|
||||||
'如果转移记录很多,同步时间可能会长(3-10分钟),'
|
'如果转移记录很多,同步时间可能会长(3-10分钟),'
|
||||||
'所以点击确定后页面没反应是正常现象,后台正在处理。'
|
'所以点击确定后页面没反应是正常现象,后台正在处理。'
|
||||||
'如果开启补充数据,会获取tr、qb种子,补充转移记录中download_hash缺失的情况(同步删除需要)。'
|
'如果开启补充数据,会获取tr、qb种子,补充转移记录中download_hash缺失的情况(同步删除需要)。'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
], {
|
], {
|
||||||
"transfer": False,
|
"transfer": False,
|
||||||
"clear": False,
|
"clear": False,
|
||||||
"supp": False,
|
"supp": False,
|
||||||
"nt_db_path": "",
|
"nt_db_path": "",
|
||||||
"path": "",
|
"path": "",
|
||||||
"downloader": "",
|
"downloader": "",
|
||||||
"site": "",
|
"site": "",
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_page(self) -> List[dict]:
|
def get_page(self) -> List[dict]:
|
||||||
pass
|
pass
|
||||||
|
@ -87,14 +87,31 @@ class SiteStatistic(_PluginBase):
|
|||||||
# 加载模块
|
# 加载模块
|
||||||
self._site_schema = ModuleHelper.load('app.plugins.sitestatistic.siteuserinfo',
|
self._site_schema = ModuleHelper.load('app.plugins.sitestatistic.siteuserinfo',
|
||||||
filter_func=lambda _, obj: hasattr(obj, 'schema'))
|
filter_func=lambda _, obj: hasattr(obj, 'schema'))
|
||||||
|
|
||||||
|
# 定时服务
|
||||||
|
self._scheduler = BackgroundScheduler(timezone=settings.TZ)
|
||||||
|
|
||||||
self._site_schema.sort(key=lambda x: x.order)
|
self._site_schema.sort(key=lambda x: x.order)
|
||||||
# 站点上一次更新时间
|
# 站点上一次更新时间
|
||||||
self._last_update_time = None
|
self._last_update_time = None
|
||||||
# 站点数据
|
# 站点数据
|
||||||
self._sites_data = {}
|
self._sites_data = {}
|
||||||
# 定时服务
|
|
||||||
self._scheduler = BackgroundScheduler(timezone=settings.TZ)
|
# 立即运行一次
|
||||||
if self._cron:
|
if self._onlyonce:
|
||||||
|
logger.info(f"站点数据统计服务启动,立即运行一次")
|
||||||
|
self._scheduler.add_job(self.refresh_all_site_data, 'date',
|
||||||
|
run_date=datetime.now(
|
||||||
|
tz=pytz.timezone(settings.TZ)) + timedelta(seconds=3)
|
||||||
|
)
|
||||||
|
# 关闭一次性开关
|
||||||
|
self._onlyonce = False
|
||||||
|
|
||||||
|
# 保存配置
|
||||||
|
self.__update_config()
|
||||||
|
|
||||||
|
# 周期运行
|
||||||
|
if self._enabled and self._cron:
|
||||||
try:
|
try:
|
||||||
self._scheduler.add_job(func=self.refresh_all_site_data,
|
self._scheduler.add_job(func=self.refresh_all_site_data,
|
||||||
trigger=CronTrigger.from_crontab(self._cron),
|
trigger=CronTrigger.from_crontab(self._cron),
|
||||||
@ -113,17 +130,6 @@ class SiteStatistic(_PluginBase):
|
|||||||
self._scheduler.add_job(self.refresh_all_site_data, "cron",
|
self._scheduler.add_job(self.refresh_all_site_data, "cron",
|
||||||
hour=trigger.hour, minute=trigger.minute,
|
hour=trigger.hour, minute=trigger.minute,
|
||||||
name="站点数据统计")
|
name="站点数据统计")
|
||||||
if self._onlyonce:
|
|
||||||
logger.info(f"站点数据统计服务启动,立即运行一次")
|
|
||||||
self._scheduler.add_job(self.refresh_all_site_data, 'date',
|
|
||||||
run_date=datetime.now(
|
|
||||||
tz=pytz.timezone(settings.TZ)) + timedelta(seconds=3)
|
|
||||||
)
|
|
||||||
# 关闭一次性开关
|
|
||||||
self._onlyonce = False
|
|
||||||
|
|
||||||
# 保存配置
|
|
||||||
self.__update_config()
|
|
||||||
|
|
||||||
# 启动任务
|
# 启动任务
|
||||||
if self._scheduler.get_jobs():
|
if self._scheduler.get_jobs():
|
||||||
@ -1034,6 +1040,9 @@ class SiteStatistic(_PluginBase):
|
|||||||
refresh_sites = [site for site in self.sites.get_indexers() if
|
refresh_sites = [site for site in self.sites.get_indexers() if
|
||||||
site.get("id") in self._statistic_sites]
|
site.get("id") in self._statistic_sites]
|
||||||
|
|
||||||
|
# 过滤掉已删除的站点
|
||||||
|
self._statistic_sites = [site.get("id") for site in refresh_sites if site]
|
||||||
|
self.__update_config()
|
||||||
if not refresh_sites:
|
if not refresh_sites:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user