mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-28 11:37:23 +08:00
feat:支持订阅绑定类别和自定义识别词
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import json
|
||||
from typing import Optional, List, Dict, Any
|
||||
|
||||
from pydantic import BaseModel, validator
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class Subscribe(BaseModel):
|
||||
@@ -65,17 +64,12 @@ class Subscribe(BaseModel):
|
||||
search_imdbid: Optional[int] = 0
|
||||
# 时间
|
||||
date: Optional[str] = None
|
||||
|
||||
@validator('sites', pre=True)
|
||||
def parse_json_fields(cls, value):
|
||||
if value:
|
||||
if isinstance(value, str):
|
||||
try:
|
||||
return json.loads(value)
|
||||
except json.JSONDecodeError:
|
||||
return []
|
||||
return value
|
||||
return []
|
||||
# 自定义识别词
|
||||
custom_words: Optional[str] = None
|
||||
# 自定义媒体类别
|
||||
media_category: Optional[str] = None
|
||||
# 过滤规则组
|
||||
filter_groups: Optional[List[str]] = []
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
+1
-13
@@ -1,7 +1,6 @@
|
||||
import json
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, validator
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
# Shared properties
|
||||
@@ -23,17 +22,6 @@ class UserBase(BaseModel):
|
||||
# 个性化设置
|
||||
settings: Optional[dict] = {}
|
||||
|
||||
@validator('permissions', 'settings', pre=True)
|
||||
def parse_json_fields(cls, value):
|
||||
if value:
|
||||
if isinstance(value, str):
|
||||
try:
|
||||
return json.loads(value)
|
||||
except json.JSONDecodeError:
|
||||
return {}
|
||||
return value
|
||||
return {}
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user