mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-07 08:26:53 +08:00
fix bug
This commit is contained in:
@@ -432,20 +432,34 @@ def subscribe_share(
|
|||||||
@router.post("/fork", summary="复用订阅", response_model=schemas.Response)
|
@router.post("/fork", summary="复用订阅", response_model=schemas.Response)
|
||||||
def subscribe_fork(
|
def subscribe_fork(
|
||||||
sub: schemas.SubscribeShare,
|
sub: schemas.SubscribeShare,
|
||||||
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
current_user: User = Depends(get_current_active_user)) -> Any:
|
||||||
"""
|
"""
|
||||||
复用订阅
|
复用订阅
|
||||||
"""
|
"""
|
||||||
sub_dict = sub.dict()
|
sub_dict = sub.dict()
|
||||||
for key in sub_dict.keys():
|
sub_dict.pop("id")
|
||||||
if not hasattr(schemas.Subscribe, key):
|
for key in list(sub_dict.keys()):
|
||||||
|
if not hasattr(schemas.Subscribe(), key):
|
||||||
sub_dict.pop(key)
|
sub_dict.pop(key)
|
||||||
result = create_subscribe(subscribe_in=schemas.Subscribe(**sub_dict))
|
result = create_subscribe(subscribe_in=schemas.Subscribe(**sub_dict),
|
||||||
|
current_user=current_user)
|
||||||
if result.success:
|
if result.success:
|
||||||
SubscribeHelper().sub_fork(share_id=sub.share_id)
|
SubscribeHelper().sub_fork(share_id=sub.id)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/shares", summary="查询分享的订阅", response_model=List[schemas.SubscribeShare])
|
||||||
|
def popular_subscribes(
|
||||||
|
name: str = None,
|
||||||
|
page: int = 1,
|
||||||
|
count: int = 30,
|
||||||
|
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||||
|
"""
|
||||||
|
查询分享的订阅
|
||||||
|
"""
|
||||||
|
return SubscribeHelper().get_shares(name=name, page=page, count=count)
|
||||||
|
|
||||||
|
|
||||||
@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,
|
||||||
|
|||||||
+22
-36
@@ -26,6 +26,8 @@ class SubscribeHelper(metaclass=Singleton):
|
|||||||
|
|
||||||
_sub_share = f"{settings.MP_SERVER_HOST}/subscribe/share"
|
_sub_share = f"{settings.MP_SERVER_HOST}/subscribe/share"
|
||||||
|
|
||||||
|
_sub_shares = f"{settings.MP_SERVER_HOST}/subscribe/shares"
|
||||||
|
|
||||||
_sub_fork = f"{settings.MP_SERVER_HOST}/subscribe/fork/%s"
|
_sub_fork = f"{settings.MP_SERVER_HOST}/subscribe/fork/%s"
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -106,21 +108,7 @@ class SubscribeHelper(metaclass=Singleton):
|
|||||||
timeout=10).post(self._sub_report,
|
timeout=10).post(self._sub_report,
|
||||||
json={
|
json={
|
||||||
"subscribes": [
|
"subscribes": [
|
||||||
{
|
sub.to_dict() for sub in subscribes
|
||||||
"name": sub.name,
|
|
||||||
"year": sub.year,
|
|
||||||
"type": sub.type,
|
|
||||||
"tmdbid": sub.tmdbid,
|
|
||||||
"imdbid": sub.imdbid,
|
|
||||||
"tvdbid": sub.tvdbid,
|
|
||||||
"doubanid": sub.doubanid,
|
|
||||||
"bangumiid": sub.bangumiid,
|
|
||||||
"season": sub.season,
|
|
||||||
"poster": sub.poster,
|
|
||||||
"backdrop": sub.backdrop,
|
|
||||||
"vote": sub.vote,
|
|
||||||
"description": sub.description
|
|
||||||
} for sub in subscribes
|
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
return True if res else False
|
return True if res else False
|
||||||
@@ -135,33 +123,15 @@ class SubscribeHelper(metaclass=Singleton):
|
|||||||
subscribe = SubscribeOper().get(subscribe_id)
|
subscribe = SubscribeOper().get(subscribe_id)
|
||||||
if not subscribe:
|
if not subscribe:
|
||||||
return False, "订阅不存在"
|
return False, "订阅不存在"
|
||||||
|
subscribe_dict = subscribe.to_dict()
|
||||||
|
subscribe_dict.pop("id")
|
||||||
res = RequestUtils(content_type="application/json",
|
res = RequestUtils(content_type="application/json",
|
||||||
timeout=10).post(self._sub_share,
|
timeout=10).post(self._sub_share,
|
||||||
json={
|
json={
|
||||||
"share_title": share_title,
|
"share_title": share_title,
|
||||||
"share_comment": share_comment,
|
"share_comment": share_comment,
|
||||||
"share_user": share_user,
|
"share_user": share_user,
|
||||||
"name": subscribe.name,
|
**subscribe_dict
|
||||||
"year": subscribe.year,
|
|
||||||
"type": subscribe.type,
|
|
||||||
"tmdbid": subscribe.tmdbid,
|
|
||||||
"imdbid": subscribe.imdbid,
|
|
||||||
"tvdbid": subscribe.tvdbid,
|
|
||||||
"doubanid": subscribe.doubanid,
|
|
||||||
"bangumiid": subscribe.bangumiid,
|
|
||||||
"season": subscribe.season,
|
|
||||||
"poster": subscribe.poster,
|
|
||||||
"backdrop": subscribe.backdrop,
|
|
||||||
"vote": subscribe.vote,
|
|
||||||
"description": subscribe.description,
|
|
||||||
"include": subscribe.include,
|
|
||||||
"exclude": subscribe.include,
|
|
||||||
"quality": subscribe.include,
|
|
||||||
"resolution": subscribe.include,
|
|
||||||
"effect": subscribe.include,
|
|
||||||
"total_episode": subscribe.include,
|
|
||||||
"custom_words": subscribe.include,
|
|
||||||
"media_category": subscribe.include,
|
|
||||||
})
|
})
|
||||||
if res is None:
|
if res is None:
|
||||||
return False, "连接MoviePilot服务器失败"
|
return False, "连接MoviePilot服务器失败"
|
||||||
@@ -185,3 +155,19 @@ class SubscribeHelper(metaclass=Singleton):
|
|||||||
return True, ""
|
return True, ""
|
||||||
else:
|
else:
|
||||||
return False, res.json().get("message")
|
return False, res.json().get("message")
|
||||||
|
|
||||||
|
@cached(cache=TTLCache(maxsize=20, ttl=1800))
|
||||||
|
def get_shares(self, name: str, page: int = 1, count: int = 30) -> List[dict]:
|
||||||
|
"""
|
||||||
|
获取订阅分享数据
|
||||||
|
"""
|
||||||
|
if not settings.SUBSCRIBE_STATISTIC_SHARE:
|
||||||
|
return []
|
||||||
|
res = RequestUtils(timeout=15).get_res(self._sub_shares, params={
|
||||||
|
"name": name,
|
||||||
|
"page": page,
|
||||||
|
"count": count
|
||||||
|
})
|
||||||
|
if res and res.status_code == 200:
|
||||||
|
return res.json()
|
||||||
|
return []
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class Subscribe(BaseModel):
|
|||||||
|
|
||||||
class SubscribeShare(BaseModel):
|
class SubscribeShare(BaseModel):
|
||||||
# 分享ID
|
# 分享ID
|
||||||
share_id: Optional[int] = None
|
id: Optional[int] = None
|
||||||
# 订阅ID
|
# 订阅ID
|
||||||
subscribe_id: Optional[int] = None
|
subscribe_id: Optional[int] = None
|
||||||
# 分享标题
|
# 分享标题
|
||||||
|
|||||||
Reference in New Issue
Block a user