mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-28 03:27:31 +08:00
fix
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import json
|
|
||||||
from typing import List, Any
|
from typing import List, Any
|
||||||
|
|
||||||
import cn2an
|
import cn2an
|
||||||
@@ -39,16 +38,7 @@ def read_subscribes(
|
|||||||
"""
|
"""
|
||||||
查询所有订阅
|
查询所有订阅
|
||||||
"""
|
"""
|
||||||
subscribes = Subscribe.list(db)
|
return Subscribe.list(db)
|
||||||
for subscribe in subscribes:
|
|
||||||
if subscribe.sites:
|
|
||||||
try:
|
|
||||||
subscribe.sites = json.loads(str(subscribe.sites))
|
|
||||||
except json.JSONDecodeError:
|
|
||||||
subscribe.sites = []
|
|
||||||
else:
|
|
||||||
subscribe.sites = []
|
|
||||||
return subscribes
|
|
||||||
|
|
||||||
|
|
||||||
@router.get("/list", summary="查询所有订阅(API_TOKEN)", response_model=List[schemas.Subscribe])
|
@router.get("/list", summary="查询所有订阅(API_TOKEN)", response_model=List[schemas.Subscribe])
|
||||||
@@ -168,11 +158,6 @@ def subscribe_mediaid(
|
|||||||
if season:
|
if season:
|
||||||
meta.begin_season = season
|
meta.begin_season = season
|
||||||
result = Subscribe.get_by_title(db, title=meta.name, season=meta.begin_season)
|
result = Subscribe.get_by_title(db, title=meta.name, season=meta.begin_season)
|
||||||
if result and result.sites:
|
|
||||||
try:
|
|
||||||
result.sites = json.loads(result.sites)
|
|
||||||
except json.JSONDecodeError:
|
|
||||||
result.sites = []
|
|
||||||
|
|
||||||
return result if result else Subscribe()
|
return result if result else Subscribe()
|
||||||
|
|
||||||
@@ -341,14 +326,7 @@ def read_subscribe(
|
|||||||
"""
|
"""
|
||||||
查询电影/电视剧订阅历史
|
查询电影/电视剧订阅历史
|
||||||
"""
|
"""
|
||||||
historys = SubscribeHistory.list_by_type(db, mtype=mtype, page=page, count=count)
|
return SubscribeHistory.list_by_type(db, mtype=mtype, page=page, count=count)
|
||||||
for history in historys:
|
|
||||||
if history and history.sites:
|
|
||||||
try:
|
|
||||||
history.sites = json.loads(history.sites)
|
|
||||||
except json.JSONDecodeError:
|
|
||||||
history.sites = []
|
|
||||||
return historys
|
|
||||||
|
|
||||||
|
|
||||||
@router.delete("/history/{history_id}", summary="删除订阅历史", response_model=schemas.Response)
|
@router.delete("/history/{history_id}", summary="删除订阅历史", response_model=schemas.Response)
|
||||||
@@ -419,13 +397,7 @@ def read_subscribe(
|
|||||||
"""
|
"""
|
||||||
if not subscribe_id:
|
if not subscribe_id:
|
||||||
return Subscribe()
|
return Subscribe()
|
||||||
subscribe = Subscribe.get(db, subscribe_id)
|
return Subscribe.get(db, subscribe_id)
|
||||||
if subscribe and subscribe.sites:
|
|
||||||
try:
|
|
||||||
subscribe.sites = json.loads(subscribe.sites)
|
|
||||||
except json.JSONDecodeError:
|
|
||||||
subscribe.sites = []
|
|
||||||
return subscribe
|
|
||||||
|
|
||||||
|
|
||||||
@router.delete("/{subscribe_id}", summary="删除订阅", response_model=schemas.Response)
|
@router.delete("/{subscribe_id}", summary="删除订阅", response_model=schemas.Response)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
import json
|
||||||
from typing import Optional, List
|
from typing import Optional, List
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel, validator
|
||||||
|
|
||||||
|
|
||||||
class Subscribe(BaseModel):
|
class Subscribe(BaseModel):
|
||||||
@@ -65,5 +66,14 @@ class Subscribe(BaseModel):
|
|||||||
# 时间
|
# 时间
|
||||||
date: Optional[str] = None
|
date: Optional[str] = None
|
||||||
|
|
||||||
|
@validator('sites', pre=True)
|
||||||
|
def parse_json_fields(cls, value):
|
||||||
|
if value:
|
||||||
|
try:
|
||||||
|
return json.loads(value)
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
raise ValueError(f"Invalid JSON string: {value}")
|
||||||
|
return {}
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
orm_mode = True
|
orm_mode = True
|
||||||
|
|||||||
Reference in New Issue
Block a user