fix 数据共享开关

This commit is contained in:
jxxghp 2024-05-06 12:37:51 +08:00
parent 90d5a8b0c9
commit ed119b7beb
3 changed files with 14 additions and 2 deletions

View File

@ -1,6 +1,7 @@
import json
from typing import List, Any
import cn2an
from fastapi import APIRouter, Request, BackgroundTasks, Depends, HTTPException, Header
from sqlalchemy.orm import Session
@ -351,7 +352,14 @@ def popular_subscribes(
for sub in subscribes:
media = MediaInfo()
media.type = MediaType(sub.get("type"))
media.title = sub.get("name")
# 处理标题
title = sub.get("name")
season = sub.get("season")
if season and int(season) > 1:
# 小写数据转大写
season_str = cn2an.an2cn(season, "low")
title = f"{title}{season_str}"
media.title = title
media.year = sub.get("year")
media.tmdb_id = sub.get("tmdbid")
media.douban_id = sub.get("doubanid")

View File

@ -81,6 +81,8 @@ class PluginHelper(metaclass=Singleton):
"""
获取插件安装统计
"""
if not settings.PLUGIN_STATISTIC_SHARE:
return {}
res = RequestUtils(timeout=10).get_res(self._install_statistic)
if res and res.status_code == 200:
return res.json()

View File

@ -29,11 +29,13 @@ class SubscribeHelper(metaclass=Singleton):
if self.sub_report():
self.systemconfig.set(SystemConfigKey.SubscribeReport, "1")
@cached(cache=TTLCache(maxsize=10, ttl=1800))
@cached(cache=TTLCache(maxsize=20, ttl=1800))
def get_statistic(self, stype: str, page: int = 1, count: int = 30) -> List[dict]:
"""
获取订阅统计数据
"""
if not settings.SUBSCRIBE_STATISTIC_SHARE:
return []
res = RequestUtils(timeout=15).get_res(self._sub_statistic, params={
"stype": stype,
"page": page,