mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
add subscribe share statistic api
This commit is contained in:
@@ -560,6 +560,15 @@ def popular_subscribes(
|
|||||||
return SubscribeHelper().get_shares(name=name, page=page, count=count)
|
return SubscribeHelper().get_shares(name=name, page=page, count=count)
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/share/statistics", summary="查询订阅分享统计", response_model=List[schemas.SubscribeShareStatistics])
|
||||||
|
def subscribe_share_statistics(_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||||
|
"""
|
||||||
|
查询订阅分享统计
|
||||||
|
返回每个分享人分享的媒体数量以及总的复用人次
|
||||||
|
"""
|
||||||
|
return SubscribeHelper().get_share_statistics()
|
||||||
|
|
||||||
|
|
||||||
@router.get("/{subscribe_id}", summary="订阅详情", response_model=schemas.Subscribe)
|
@router.get("/{subscribe_id}", summary="订阅详情", response_model=schemas.Subscribe)
|
||||||
def read_subscribe(
|
def read_subscribe(
|
||||||
subscribe_id: int,
|
subscribe_id: int,
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ class SubscribeHelper(metaclass=WeakSingleton):
|
|||||||
|
|
||||||
_sub_shares = f"{settings.MP_SERVER_HOST}/subscribe/shares"
|
_sub_shares = f"{settings.MP_SERVER_HOST}/subscribe/shares"
|
||||||
|
|
||||||
|
_sub_share_statistic = f"{settings.MP_SERVER_HOST}/subscribe/share/statistic"
|
||||||
|
|
||||||
_sub_fork = f"{settings.MP_SERVER_HOST}/subscribe/fork/%s"
|
_sub_fork = f"{settings.MP_SERVER_HOST}/subscribe/fork/%s"
|
||||||
|
|
||||||
_shares_cache_region = "subscribe_share"
|
_shares_cache_region = "subscribe_share"
|
||||||
@@ -215,6 +217,18 @@ class SubscribeHelper(metaclass=WeakSingleton):
|
|||||||
return res.json()
|
return res.json()
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@cached(maxsize=1, ttl=1800)
|
||||||
|
def get_share_statistics(self) -> List[dict]:
|
||||||
|
"""
|
||||||
|
获取订阅分享统计数据
|
||||||
|
"""
|
||||||
|
if not settings.SUBSCRIBE_STATISTIC_SHARE:
|
||||||
|
return []
|
||||||
|
res = RequestUtils(proxies=settings.PROXY, timeout=15).get_res(self._sub_share_statistic)
|
||||||
|
if res and res.status_code == 200:
|
||||||
|
return res.json()
|
||||||
|
return []
|
||||||
|
|
||||||
def get_user_uuid(self) -> str:
|
def get_user_uuid(self) -> str:
|
||||||
"""
|
"""
|
||||||
获取用户uuid
|
获取用户uuid
|
||||||
|
|||||||
@@ -138,6 +138,15 @@ class SubscribeShare(BaseModel):
|
|||||||
count: Optional[int] = 0
|
count: Optional[int] = 0
|
||||||
|
|
||||||
|
|
||||||
|
class SubscribeShareStatistics(BaseModel):
|
||||||
|
# 分享人
|
||||||
|
share_user: Optional[str] = None
|
||||||
|
# 分享数量
|
||||||
|
share_count: Optional[int] = 0
|
||||||
|
# 总复用人次
|
||||||
|
total_reuse_count: Optional[int] = 0
|
||||||
|
|
||||||
|
|
||||||
class SubscribeDownloadFileInfo(BaseModel):
|
class SubscribeDownloadFileInfo(BaseModel):
|
||||||
# 种子名称
|
# 种子名称
|
||||||
torrent_title: Optional[str] = None
|
torrent_title: Optional[str] = None
|
||||||
|
|||||||
Reference in New Issue
Block a user