mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-28 19:47:41 +08:00
feat(filter): 支持音乐优先级规则组
This commit is contained in:
@@ -4,15 +4,13 @@ import copy
|
||||
import re
|
||||
from typing import Any, Dict, Iterable, Optional
|
||||
|
||||
from app.runtime.events import eventmanager
|
||||
from app.application.agentdata import get_agent_subscribe_port
|
||||
from app.application.configuration import get_configured_system_config
|
||||
from app.application.rules import RuleHelper
|
||||
from app.application.rules import RuleParser
|
||||
from app.application.rules import BUILTIN_RULE_SET
|
||||
from app.application.rules import BUILTIN_RULE_SET, RuleHelper, RuleParser
|
||||
from app.runtime.events import eventmanager
|
||||
from app.schemas.event import ConfigChangeEventData
|
||||
from app.schemas.rule import CustomRule
|
||||
from app.schemas.system import FilterRuleGroup
|
||||
from app.schemas.event import ConfigChangeEventData
|
||||
from app.schemas.types import EventType, SystemConfigKey
|
||||
|
||||
RULE_ID_PATTERN = re.compile(r"^[A-Za-z0-9]+$")
|
||||
@@ -27,8 +25,10 @@ MEDIA_TYPE_ALIASES = {
|
||||
"tv": "电视剧",
|
||||
"series": "电视剧",
|
||||
"show": "电视剧",
|
||||
"music": "音乐",
|
||||
"电影": "电影",
|
||||
"电视剧": "电视剧",
|
||||
"音乐": "音乐",
|
||||
}
|
||||
|
||||
RULE_STRING_SYNTAX = {
|
||||
@@ -76,9 +76,9 @@ def normalize_media_type(value: Optional[str]) -> Optional[str]:
|
||||
if not value:
|
||||
return None
|
||||
normalized = MEDIA_TYPE_ALIASES.get(value.lower(), value)
|
||||
if normalized not in {"电影", "电视剧"}:
|
||||
if normalized not in {"电影", "电视剧", "音乐"}:
|
||||
raise ValueError(
|
||||
"media_type 仅支持 '电影'、'电视剧'、'movie' 或 'tv'"
|
||||
"media_type 仅支持 '电影'、'电视剧'、'音乐'、'movie'、'tv' 或 'music'"
|
||||
)
|
||||
return normalized
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ from typing import Optional, Type
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from app.agent.tools.base import MoviePilotTool
|
||||
from app.agent.tools.tags import ToolTag
|
||||
from app.agent.tools.impl._filter_rule_utils import (
|
||||
build_custom_rule_map,
|
||||
collect_rule_group_usages,
|
||||
@@ -17,6 +16,7 @@ from app.agent.tools.impl._filter_rule_utils import (
|
||||
save_system_config,
|
||||
serialize_rule_group,
|
||||
)
|
||||
from app.agent.tools.tags import ToolTag
|
||||
from app.runtime.log import logger
|
||||
from app.schemas.types import SystemConfigKey
|
||||
|
||||
@@ -35,7 +35,7 @@ class AddRuleGroupInput(BaseModel):
|
||||
)
|
||||
media_type: Optional[str] = Field(
|
||||
None,
|
||||
description="Optional media type scope: '电影', '电视剧', 'movie', or 'tv'.",
|
||||
description="Optional media type scope: '电影', '电视剧', '音乐', 'movie', 'tv', or 'music'.",
|
||||
)
|
||||
category: Optional[str] = Field(
|
||||
None,
|
||||
|
||||
@@ -6,7 +6,18 @@
|
||||
import threading
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from pyparsing import Forward, Literal, Word, alphas, infix_notation, opAssoc, alphanums, Combine, nums, ParseResults
|
||||
from pyparsing import (
|
||||
Combine,
|
||||
Forward,
|
||||
Literal,
|
||||
ParseResults,
|
||||
Word,
|
||||
alphanums,
|
||||
alphas,
|
||||
infix_notation,
|
||||
nums,
|
||||
opAssoc,
|
||||
)
|
||||
|
||||
from app.adapters.system import rust as rust_accel
|
||||
from app.application.configuration import get_configured_system_config
|
||||
@@ -53,10 +64,8 @@ class RuleHelper:
|
||||
if not group.media_type
|
||||
or (
|
||||
media
|
||||
and (
|
||||
(not group.category and group.media_type == media.type.value)
|
||||
or group.category == media.category
|
||||
)
|
||||
and group.media_type == media.type.value
|
||||
and (not group.category or group.category == media.category)
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ class FilterRuleGroup(BaseModel):
|
||||
name: Optional[str] = None
|
||||
# 规则串
|
||||
rule_string: Optional[str] = None
|
||||
# 适用类媒体类型 None-全部 电影/电视剧
|
||||
# 适用媒体类型 None-全部 电影/电视剧/音乐
|
||||
media_type: Optional[str] = None
|
||||
# 适用媒体类别 None-全部 对应二级分类
|
||||
category: Optional[str] = None
|
||||
|
||||
Reference in New Issue
Block a user