This commit is contained in:
jxxghp 2023-07-11 07:21:48 +08:00
parent bfddd98ae2
commit 8a4a66dec4
7 changed files with 35 additions and 24 deletions

View File

@ -34,7 +34,10 @@ def storage(_: schemas.TokenPayload = Depends(verify_token)) -> Any:
"""
查询存储空间信息
"""
total_storage, free_storage = SystemUtils.space_usage(Path(settings.LIBRARY_PATH))
if settings.LIBRARY_PATH:
total_storage, free_storage = SystemUtils.space_usage(Path(settings.LIBRARY_PATH))
else:
total_storage, free_storage = 0, 0
return schemas.Storage(
total_storage=total_storage,
used_storage=total_storage - free_storage
@ -75,6 +78,8 @@ def schedule(_: schemas.TokenPayload = Depends(verify_token)) -> Any:
# 去重
added = []
jobs = Scheduler().list()
# 按照下次运行时间排序
jobs.sort(key=lambda x: x.next_run_time)
for job in jobs:
if job.name not in added:
added.append(job.name)

View File

@ -44,8 +44,8 @@ class SearchChain(ChainBase):
return []
results = self.process(mediainfo=mediainfo)
# 保存眲结果
self.systemconfig.set(SystemConfigKey.SearchResults,
pickle.dumps(results))
bytes_results = pickle.dumps(results)
self.systemconfig.set(SystemConfigKey.SearchResults, bytes_results)
return results
def search_by_title(self, title: str) -> List[TorrentInfo]:
@ -206,10 +206,10 @@ class SearchChain(ChainBase):
# 未开启的站点不搜索
indexer_sites = []
# 配置的索引站点
config_indexers = self.systemconfig.get(SystemConfigKey.IndexerSites) or []
config_indexers = [str(sid) for sid in self.systemconfig.get(SystemConfigKey.IndexerSites) or []]
for indexer in self.siteshelper.get_indexers():
# 检查站点索引开关
if not config_indexers or indexer.get("id") in config_indexers:
if not config_indexers or str(indexer.get("id")) in config_indexers:
# 站点流控
state, msg = self.siteshelper.check(indexer.get("domain"))
if not state:

View File

@ -272,11 +272,11 @@ class SubscribeChain(ChainBase):
# 所有站点索引
indexers = self.siteshelper.get_indexers()
# 配置的索引站点
config_indexers = self.systemconfig.get(SystemConfigKey.IndexerSites) or []
config_indexers = [str(sid) for sid in self.systemconfig.get(SystemConfigKey.IndexerSites) or []]
# 遍历站点缓存资源
for indexer in indexers:
# 未开启的站点不搜索
if config_indexers and indexer.get("id") not in config_indexers:
if config_indexers and str(indexer.get("id")) not in config_indexers:
continue
logger.info(f'开始刷新站点资源,站点:{indexer.get("name")} ...')
domain = StringUtils.get_url_domain(indexer.get("domain"))

View File

@ -55,9 +55,6 @@ class TorrentInfo:
# 种子优先级
pri_order: int = 0
def __getattr__(self, attribute):
return None
def __setattr__(self, name: str, value: Any):
self.__dict__[name] = value
@ -175,9 +172,6 @@ class MediaInfo:
if self.douban_info:
self.set_douban_info(self.douban_info)
def __getattr__(self, attribute):
return None
def __setattr__(self, name: str, value: Any):
self.__dict__[name] = value
@ -518,9 +512,6 @@ class Context:
# 种子信息
torrent_info: TorrentInfo = None
def __getattr__(self, attribute):
return None
def __setattr__(self, name: str, value: Any):
self.__dict__[name] = value

View File

@ -7,10 +7,18 @@ class ObjectUtils:
@staticmethod
def is_obj(obj: Any):
if isinstance(obj, list) or isinstance(obj, dict):
if isinstance(obj, list) \
or isinstance(obj, dict):
return True
elif isinstance(obj, str) \
or isinstance(obj, int) \
or isinstance(obj, float) \
or isinstance(obj, bool) \
or isinstance(obj, bytes):
return False
else:
return str(obj).startswith("{") or str(obj).startswith("[")
return str(obj).startswith("{") \
or str(obj).startswith("[")
@staticmethod
def arguments(func: Callable) -> int:

View File

@ -42,11 +42,17 @@ class TimerUtils:
@staticmethod
def time_difference(input_datetime: datetime) -> str:
"""
判断输入时间与当前的时间差如果输入时间大于当前时间则返回时间差否则返回空字符串
"""
if not input_datetime:
return ""
current_datetime = datetime.datetime.now(datetime.timezone.utc).astimezone()
time_difference = input_datetime - current_datetime
if time_difference.total_seconds() < 0:
return ""
days = time_difference.days
hours, remainder = divmod(time_difference.seconds, 3600)
minutes, _ = divmod(remainder, 60)

View File

@ -27,6 +27,7 @@ http {
location / {
# 主目录
expires off;
add_header Cache-Control "no-cache, no-store, must-revalidate";
root /app/public;
@ -34,6 +35,7 @@ http {
}
location /assets {
# 静态资源
expires 7d;
add_header Cache-Control "public";
}
@ -53,13 +55,15 @@ http {
proxy_pass http://backend_api;
}
location ~ ^/(api/v1/system/message|api/v1/system/progress/) {
location ~ ^/api/v1/system/(message|progress/) {
# SSE MIME类型设置
default_type text/event-stream;
# 禁用缓存
add_header Cache-Control no-cache;
add_header X-Accel-Buffering no;
proxy_buffering off;
proxy_cache off;
# 代理设置
proxy_pass http://backend_api;
@ -87,13 +91,10 @@ http {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Nginx-Proxy true;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
# 超时设置
proxy_read_timeout 600s;
}
}
upstream backend_api {