feat: filter site bodies before media upload
This commit is contained in:
@@ -37,6 +37,10 @@ class SourceItem:
|
||||
media: list[SourceMedia] = field(default_factory=list)
|
||||
raw: dict[str, Any] = field(default_factory=dict)
|
||||
|
||||
@property
|
||||
def body_text(self) -> str:
|
||||
return str(self.raw.get("text") or "").strip()
|
||||
|
||||
|
||||
def validate_source_config(platform: str, config: dict[str, Any]) -> None:
|
||||
if platform == PLATFORM_VK:
|
||||
@@ -60,6 +64,12 @@ def validate_source_config(platform: str, config: dict[str, Any]) -> None:
|
||||
raise ValueError("follow_links должен быть true или false")
|
||||
if follow_links and not str(config.get("content_selector") or "").strip():
|
||||
raise ValueError("При follow_links=true нужен content_selector")
|
||||
try:
|
||||
min_text_length = int(config.get("min_text_length", 0))
|
||||
except (TypeError, ValueError) as exc:
|
||||
raise ValueError("min_text_length должен быть целым числом") from exc
|
||||
if not 0 <= min_text_length <= 100_000:
|
||||
raise ValueError("min_text_length должен быть от 0 до 100000")
|
||||
|
||||
|
||||
def _posted_at(value: Any) -> datetime:
|
||||
|
||||
Reference in New Issue
Block a user