Merge branch 'jxxghp:main' into wlj0909

This commit is contained in:
developer-wlj 2023-09-27 18:06:51 +08:00 committed by GitHub
commit 20711e17fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 20 deletions

View File

@ -31,7 +31,7 @@ def read_sites(db: Session = Depends(get_db),
@router.post("/", summary="新增站点", response_model=schemas.Response) @router.post("/", summary="新增站点", response_model=schemas.Response)
def update_site( def add_site(
*, *,
db: Session = Depends(get_db), db: Session = Depends(get_db),
site_in: schemas.Site, site_in: schemas.Site,

View File

@ -88,7 +88,7 @@ def update_subscribe(
subscribe = Subscribe.get(db, subscribe_in.id) subscribe = Subscribe.get(db, subscribe_in.id)
if not subscribe: if not subscribe:
return schemas.Response(success=False, message="订阅不存在") return schemas.Response(success=False, message="订阅不存在")
if subscribe_in.sites: if subscribe_in.sites is not None:
subscribe_in.sites = json.dumps(subscribe_in.sites) subscribe_in.sites = json.dumps(subscribe_in.sites)
# 避免更新缺失集数 # 避免更新缺失集数
subscribe_dict = subscribe_in.dict() subscribe_dict = subscribe_in.dict()

View File

@ -120,6 +120,9 @@ class BrushFlow(_PluginBase):
self.save_data("statistic", {}) self.save_data("statistic", {})
# 清除种子记录 # 清除种子记录
self.save_data("torrents", {}) self.save_data("torrents", {})
# 关闭一次性开关
self._clear_task = False
self.__update_config()
# 停止现有任务 # 停止现有任务
self.stop_service() self.stop_service()
@ -729,6 +732,7 @@ class BrushFlow(_PluginBase):
"enabled": False, "enabled": False,
"notify": True, "notify": True,
"onlyonce": False, "onlyonce": False,
"clear_task": False,
"freeleech": "free" "freeleech": "free"
} }
@ -1218,7 +1222,8 @@ class BrushFlow(_PluginBase):
"seed_inactivetime": self._seed_inactivetime, "seed_inactivetime": self._seed_inactivetime,
"up_speed": self._up_speed, "up_speed": self._up_speed,
"dl_speed": self._dl_speed, "dl_speed": self._dl_speed,
"save_path": self._save_path "save_path": self._save_path,
"clear_task": self._clear_task
}) })
def brush(self): def brush(self):
@ -1265,12 +1270,6 @@ class BrushFlow(_PluginBase):
f"{task.get('site_name')}{task.get('title')}" for task in task_info.values() f"{task.get('site_name')}{task.get('title')}" for task in task_info.values()
]: ]:
continue continue
# 保种体积GB 促销
if self._disksize \
and (torrents_size + torrent.size) > float(self._disksize) * 1024**3:
logger.warn(f"当前做种体积 {StringUtils.str_filesize(torrents_size)} "
f"已超过保种体积 {self._disksize},停止新增任务")
break
# 促销 # 促销
if self._freeleech and torrent.downloadvolumefactor != 0: if self._freeleech and torrent.downloadvolumefactor != 0:
continue continue
@ -1349,6 +1348,12 @@ class BrushFlow(_PluginBase):
logger.warn(f"当前总下载带宽 {StringUtils.str_filesize(current_download_speed)} " logger.warn(f"当前总下载带宽 {StringUtils.str_filesize(current_download_speed)} "
f"已达到最大值 {self._maxdlspeed} KB/s暂时停止新增任务") f"已达到最大值 {self._maxdlspeed} KB/s暂时停止新增任务")
break break
# 保种体积GB
if self._disksize \
and (torrents_size + torrent.size) > float(self._disksize) * 1024**3:
logger.warn(f"当前做种体积 {StringUtils.str_filesize(torrents_size)} "
f"已超过保种体积 {self._disksize},停止新增任务")
break
# 添加下载任务 # 添加下载任务
hash_string = self.__download(torrent=torrent) hash_string = self.__download(torrent=torrent)
if not hash_string: if not hash_string:
@ -1767,19 +1772,22 @@ class BrushFlow(_PluginBase):
""" """
发送删除种子的消息 发送删除种子的消息
""" """
if self._notify: if not self._notify:
self.chain.post_message(Notification( return
mtype=NotificationType.SiteMessage, self.chain.post_message(Notification(
title=f"【刷流任务删种】", mtype=NotificationType.SiteMessage,
text=f"站点:{site_name}\n" title=f"【刷流任务删种】",
f"标题:{torrent_title}\n" text=f"站点:{site_name}\n"
f"原因:{reason}" f"标题:{torrent_title}\n"
)) f"原因:{reason}"
))
def __send_add_message(self, torrent: TorrentInfo): def __send_add_message(self, torrent: TorrentInfo):
""" """
发送添加下载的消息 发送添加下载的消息
""" """
if not self._notify:
return
msg_text = "" msg_text = ""
if torrent.site_name: if torrent.site_name:
msg_text = f"站点:{torrent.site_name}" msg_text = f"站点:{torrent.site_name}"

View File

@ -349,9 +349,9 @@ class SystemUtils:
# 获取当前容器的 ID # 获取当前容器的 ID
with open('/proc/self/mountinfo', 'r') as f: with open('/proc/self/mountinfo', 'r') as f:
data = f.read() data = f.read()
index_resolv_conf = data.find("/sys/fs/cgroup/devices") index_resolv_conf = data.find("resolv.conf")
if index_resolv_conf != -1: if index_resolv_conf != -1:
index_second_slash = data.rfind(" ", 0, index_resolv_conf) index_second_slash = data.rfind("/", 0, index_resolv_conf)
index_first_slash = data.rfind("/", 0, index_second_slash) + 1 index_first_slash = data.rfind("/", 0, index_second_slash) + 1
container_id = data[index_first_slash:index_second_slash] container_id = data[index_first_slash:index_second_slash]
if not container_id: if not container_id:

View File

@ -1 +1 @@
APP_VERSION = 'v1.2.5' APP_VERSION = 'v1.2.6'