mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-06-12 19:21:05 +08:00
add action templates
This commit is contained in:
@@ -2,7 +2,7 @@ from abc import ABC, abstractmethod
|
|||||||
|
|
||||||
from pydantic.main import BaseModel
|
from pydantic.main import BaseModel
|
||||||
|
|
||||||
from app.schemas import ActionContext
|
from app.schemas import ActionContext, ActionParams
|
||||||
|
|
||||||
|
|
||||||
class BaseAction(BaseModel, ABC):
|
class BaseAction(BaseModel, ABC):
|
||||||
@@ -21,5 +21,5 @@ class BaseAction(BaseModel, ABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
async def execute(self, params: dict, context: ActionContext) -> ActionContext:
|
async def execute(self, params: ActionParams, context: ActionContext) -> ActionContext:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|||||||
0
app/actions/add_download.py
Normal file
0
app/actions/add_download.py
Normal file
0
app/actions/add_subscribe.py
Normal file
0
app/actions/add_subscribe.py
Normal file
0
app/actions/fetch_medias.py
Normal file
0
app/actions/fetch_medias.py
Normal file
33
app/actions/fetch_rss.py
Normal file
33
app/actions/fetch_rss.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from pydantic import Field
|
||||||
|
|
||||||
|
from app.actions import BaseAction
|
||||||
|
from app.schemas import ActionParams, ActionContext
|
||||||
|
|
||||||
|
|
||||||
|
class FetchRssParams(ActionParams):
|
||||||
|
"""
|
||||||
|
获取RSS资源列表参数
|
||||||
|
"""
|
||||||
|
url: str = Field(None, description="RSS地址")
|
||||||
|
proxy: Optional[bool] = Field(False, description="是否使用代理")
|
||||||
|
timeout: Optional[int] = Field(15, description="超时时间")
|
||||||
|
headers: Optional[dict] = Field(None, description="请求头")
|
||||||
|
recognize: Optional[bool] = Field(False, description="是否识别")
|
||||||
|
|
||||||
|
|
||||||
|
class FetchRssAction(BaseAction):
|
||||||
|
"""
|
||||||
|
获取RSS资源列表
|
||||||
|
"""
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return "获取RSS资源列表"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def description(self) -> str:
|
||||||
|
return "请求RSS地址获取数据,并解析为资源列表"
|
||||||
|
|
||||||
|
async def execute(self, params: FetchRssParams, context: ActionContext) -> ActionContext:
|
||||||
|
pass
|
||||||
0
app/actions/filter_medias.py
Normal file
0
app/actions/filter_medias.py
Normal file
0
app/actions/filter_torrents.py
Normal file
0
app/actions/filter_torrents.py
Normal file
34
app/actions/search_torrents.py
Normal file
34
app/actions/search_torrents.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from pydantic import Field
|
||||||
|
|
||||||
|
from app.actions import BaseAction
|
||||||
|
from app.schemas import ActionParams, ActionContext
|
||||||
|
|
||||||
|
|
||||||
|
class SearchTorrentsParams(ActionParams):
|
||||||
|
"""
|
||||||
|
搜索站点资源参数
|
||||||
|
"""
|
||||||
|
name: str = Field(None, description="资源名称")
|
||||||
|
year: Optional[int] = Field(None, description="年份")
|
||||||
|
type: Optional[str] = Field(None, description="资源类型 (电影/电视剧)")
|
||||||
|
season: Optional[int] = Field(None, description="季度")
|
||||||
|
recognize: Optional[bool] = Field(False, description="是否识别")
|
||||||
|
|
||||||
|
|
||||||
|
class SearchTorrentsAction(BaseAction):
|
||||||
|
"""
|
||||||
|
搜索站点资源
|
||||||
|
"""
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return "搜索站点资源"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def description(self) -> str:
|
||||||
|
return "根据关键字搜索站点种子资源"
|
||||||
|
|
||||||
|
async def execute(self, params: SearchTorrentsParams, context: ActionContext) -> ActionContext:
|
||||||
|
pass
|
||||||
0
app/actions/send_event.py
Normal file
0
app/actions/send_event.py
Normal file
0
app/actions/send_message.py
Normal file
0
app/actions/send_message.py
Normal file
0
app/actions/transfer_file.py
Normal file
0
app/actions/transfer_file.py
Normal file
@@ -1,8 +1,9 @@
|
|||||||
from abc import ABC, abstractmethod
|
from typing import Optional, List, Tuple
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
|
from app.schemas import Context, MediaInfo, FileItem, Site, Subscribe, Notification
|
||||||
|
|
||||||
|
|
||||||
class Workflow(BaseModel):
|
class Workflow(BaseModel):
|
||||||
"""
|
"""
|
||||||
@@ -28,8 +29,22 @@ class Action(BaseModel):
|
|||||||
description: Optional[str] = Field(None, description="动作描述")
|
description: Optional[str] = Field(None, description="动作描述")
|
||||||
|
|
||||||
|
|
||||||
class ActionContext(BaseModel, ABC):
|
class ActionContext(BaseModel):
|
||||||
"""
|
"""
|
||||||
动作上下文
|
动作基础上下文,各动作通用数据
|
||||||
|
"""
|
||||||
|
content: Optional[str] = Field(None, description="文本类内容")
|
||||||
|
torrents: Optional[List[Context]] = Field([], description="资源列表")
|
||||||
|
medias: Optional[List[MediaInfo]] = Field([], description="媒体列表")
|
||||||
|
fileitems: Optional[List[FileItem]] = Field([], description="文件列表")
|
||||||
|
downloads: Optional[List[Tuple[str, str]]] = Field([], description="下载任务列表")
|
||||||
|
sites: Optional[List[Site]] = Field([], description="站点列表")
|
||||||
|
subscribes: Optional[List[Subscribe]] = Field([], description="订阅列表")
|
||||||
|
messages: Optional[List[Notification]] = Field([], description="消息列表")
|
||||||
|
|
||||||
|
|
||||||
|
class ActionParams(BaseModel):
|
||||||
|
"""
|
||||||
|
动作基础参数
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user